Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Selwyn Simsek
gsll
Commits
e522dde8
Commit
e522dde8
authored
Jan 17, 2010
by
Liam Healy
Browse files
Random number generator type symbols in keyword package
parent
4c9c711a
Changes
73
Hide whitespace changes
Inline
Side-by-side
basis-splines.lisp
View file @
e522dde8
;; Basis splines.
;; Liam Healy 2008-02-18 14:43:20EST basis-splines.lisp
;; Time-stamp: <20
09-12-27 09:42:10
EST basis-splines.lisp>
;; Time-stamp: <20
10-01-17 10:41:03
EST basis-splines.lisp>
;;
;; Copyright 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
...
...
@@ -124,7 +124,7 @@
(
dotimes
(
i
ndata
)
(
let*
((
xi
(
coerce
(
*
i
(
/
15
(
1-
ndata
)))
'double-float
))
(
yi
(
+
(
*
(
cos
xi
)
(
exp
(
*
-0.1d0
xi
)))
(
sample
rng
'
gaussian
:sigma
sigma
))))
(
sample
rng
:
gaussian
:sigma
sigma
))))
(
setf
(
maref
x
i
)
xi
(
maref
y
i
)
yi
(
maref
w
i
)
(
/
(
expt
sigma
2
)))))
...
...
random/bernoulli.lisp
View file @
e522dde8
;; Bernoulli distribution
;; Liam Healy, Sat Nov 25 2006 - 16:59
;; Time-stamp: <20
09-12-2
7 10:0
0
:0
4
EST bernoulli.lisp>
;; Time-stamp: <20
10-01-1
7 10:0
6
:0
6
EST bernoulli.lisp>
;;
;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
...
...
@@ -20,9 +20,8 @@
(
in-package
:gsl
)
(
export
'bernoulli
)
(
defmfun
sample
((
generator
random-number-generator
)
(
type
(
eql
'
bernoulli
))
((
generator
random-number-generator
)
(
type
(
eql
:
bernoulli
))
&key
probability
)
"gsl_ran_bernoulli"
(((
mpointer
generator
)
:pointer
)
(
probability
:double
))
...
...
@@ -41,12 +40,12 @@
:documentation
; FDL
"The probability p(k) of obtaining
k from a Bernoulli distribution with probability parameter
p, using the formula given in #'bernoulli."
)
p, using the formula given in #'
sample :
bernoulli."
)
;;; Examples and unit test
(
save-test
bernoulli
(
let
((
rng
(
make-random-number-generator
+mt19937+
0
)))
(
loop
for
i
from
0
to
10
collect
(
sample
rng
'
bernoulli
:probability
0.5d0
)))
(
sample
rng
:
bernoulli
:probability
0.5d0
)))
(
bernoulli-pdf
0
0.5d0
))
random/beta.lisp
View file @
e522dde8
;; Beta distribution
;; Liam Healy, Sat Sep 30 2006
;; Time-stamp: <20
09-12-2
7 10:0
0:04
EST beta.lisp>
;; Time-stamp: <20
10-01-1
7 10:0
5:21
EST beta.lisp>
;;
;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
...
...
@@ -20,9 +20,8 @@
(
in-package
:gsl
)
(
export
'beta
)
(
defmfun
sample
((
generator
random-number-generator
)
(
type
(
eql
'
beta
))
&key
a
b
)
((
generator
random-number-generator
)
(
type
(
eql
:
beta
))
&key
a
b
)
"gsl_ran_beta"
(((
mpointer
generator
)
:pointer
)
(
a
:double
)
(
b
:double
))
:definition
:method
...
...
@@ -38,7 +37,7 @@
:documentation
; FDL
"The probability density p(x) at x
for a beta distribution with parameters a and b, using the
formula given in #'beta."
)
formula given in #'
sample :
beta."
)
(
defmfun
beta-P
(
x
a
b
)
"gsl_cdf_beta_P"
((
x
:double
)
(
a
:double
)
(
b
:double
))
...
...
@@ -73,7 +72,7 @@
(
let
((
rng
(
make-random-number-generator
+mt19937+
0
)))
(
loop
for
i
from
0
to
10
collect
(
sample
rng
'
beta
:a
1.0d0
:b
2.0d0
)))
(
sample
rng
:
beta
:a
1.0d0
:b
2.0d0
)))
(
beta-pdf
0.1d0
1.0d0
2.0d0
)
(
beta-P
0.1d0
1.0d0
2.0d0
)
(
beta-Q
0.1d0
1.0d0
2.0d0
)
...
...
random/cauchy.lisp
View file @
e522dde8
;; Cauchy distribution
;; Liam Healy, Sat Sep 30 2006
;; Time-stamp: <20
09-12-2
7 10:0
0:03
EST cauchy.lisp>
;; Time-stamp: <20
10-01-1
7 10:0
5:32
EST cauchy.lisp>
;;
;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
...
...
@@ -23,9 +23,8 @@
;;; /usr/include/gsl/gsl_randist.h
;;; /usr/include/gsl/gsl_cdf.h
(
export
'cauchy
)
(
defmfun
sample
((
generator
random-number-generator
)
(
type
(
eql
'
cauchy
))
&key
a
)
((
generator
random-number-generator
)
(
type
(
eql
:
cauchy
))
&key
a
)
"gsl_ran_cauchy"
(((
mpointer
generator
)
:pointer
)
(
a
:double
))
:definition
:method
...
...
@@ -44,7 +43,7 @@
:documentation
; FDL
"The probability density p(x) at x
for a Cauchy distribution with scale parameter a, using the formula
given for #'cauchy."
)
given for #'
sample :
cauchy."
)
(
defmfun
cauchy-P
(
x
a
)
"gsl_cdf_cauchy_P"
((
x
:double
)
(
a
:double
))
...
...
@@ -79,7 +78,7 @@
(
let
((
rng
(
make-random-number-generator
+mt19937+
0
)))
(
loop
for
i
from
0
to
10
collect
(
sample
rng
'
cauchy
:a
10.0d0
)))
(
sample
rng
:
cauchy
:a
10.0d0
)))
(
cauchy-pdf
0.0d0
10.0d0
)
(
cauchy-P
1.0d0
2.0d0
)
(
cauchy-Q
1.0d0
2.0d0
)
...
...
random/chi-squared.lisp
View file @
e522dde8
;; Chi-squared distribution
;; Liam Healy, Sat Oct 7 2006 - 16:13
;; Time-stamp: <20
09-12-2
7 10:0
0:03
EST chi-squared.lisp>
;; Time-stamp: <20
10-01-1
7 10:0
7:11
EST chi-squared.lisp>
;;
;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
...
...
@@ -23,9 +23,8 @@
;;; /usr/include/gsl/gsl_randist.h
;;; /usr/include/gsl/gsl_cdf.h
(
export
'chi-squared
)
(
defmfun
sample
((
generator
random-number-generator
)
(
type
(
eql
'
chi-squared
))
&key
nu
)
((
generator
random-number-generator
)
(
type
(
eql
:
chi-squared
))
&key
nu
)
"gsl_ran_chisq"
(((
mpointer
generator
)
:pointer
)
(
nu
:double
))
:definition
:method
...
...
@@ -42,7 +41,7 @@
:documentation
; FDL
"The probability density p(x) at x
for a chi-squared distribution with nu degrees of freedom, using
the formula given in #'chi-squared."
)
the formula given in #'
sample :
chi-squared."
)
(
defmfun
chi-squared-P
(
x
nu
)
"gsl_cdf_chisq_P"
((
x
:double
)
(
nu
:double
))
...
...
@@ -77,7 +76,7 @@
(
let
((
rng
(
make-random-number-generator
+mt19937+
0
)))
(
loop
for
i
from
0
to
10
collect
(
sample
rng
'
chi-squared
:nu
10.0d0
)))
(
sample
rng
:
chi-squared
:nu
10.0d0
)))
(
chi-squared-pdf
0.5d0
1.0d0
)
(
chi-squared-P
0.5d0
1.0d0
)
(
chi-squared-Q
0.5d0
1.0d0
)
...
...
random/dirichlet.lisp
View file @
e522dde8
;; Dirichlet distribution
;; Liam Healy, Sun Oct 29 2006
;; Time-stamp: <20
09-12-2
7 10:0
0:02
EST dirichlet.lisp>
;; Time-stamp: <20
10-01-1
7 10:0
9:21
EST dirichlet.lisp>
;;
;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
...
...
@@ -22,9 +22,8 @@
;;; /usr/include/gsl/gsl_randist.h
(
export
'dirichlet
)
(
defmfun
sample
((
generator
random-number-generator
)
(
type
(
eql
'
dirichlet
))
((
generator
random-number-generator
)
(
type
(
eql
:
dirichlet
))
&key
alpha
(
theta
(
vdf
(
dim0
alpha
))))
"gsl_ran_dirichlet"
(((
mpointer
generator
)
:pointer
)
...
...
@@ -64,7 +63,7 @@
:documentation
; FDL
"The probability density p(\theta_1, ... , \theta_K)
at theta[K] for a Dirichlet distribution with parameters
alpha[K], using the formula given for #'dirichlet."
)
alpha[K], using the formula given for #'
sample :
dirichlet."
)
(
defmfun
dirichlet-log-pdf
(
alpha
theta
)
"gsl_ran_dirichlet_lnpdf"
...
...
@@ -84,7 +83,7 @@
(
save-test
dirichlet
(
let
((
rng
(
make-random-number-generator
+mt19937+
0
))
(
alpha
#
m
(
1.0d0
2.0d0
3.0d0
4.0d0
)))
(
cl-array
(
sample
rng
'
dirichlet
:alpha
alpha
)))
(
cl-array
(
sample
rng
:
dirichlet
:alpha
alpha
)))
(
let
((
alpha
#
m
(
1.0d0
2.0d0
3.0d0
4.0d0
))
(
theta
#
m
(
1.0d0
2.0d0
3.0d0
4.0d0
)))
(
dirichlet-pdf
alpha
theta
))
...
...
random/discrete.lisp
View file @
e522dde8
;; Discrete random variables
;; Liam Healy, Sat Nov 11 2006 - 21:51
;; Time-stamp: <20
09-12-27 10:00:02
EST discrete.lisp>
;; Time-stamp: <20
10-01-17 10:10:00
EST discrete.lisp>
;;
;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
...
...
@@ -35,9 +35,8 @@
generally as ``weights'')---the preprocessor will normalize appropriately.
This return value is used as an argument to #'discrete."
)
(
export
'discrete
)
(
defmfun
sample
((
generator
random-number-generator
)
(
type
(
eql
'
discrete
))
((
generator
random-number-generator
)
(
type
(
eql
:
discrete
))
&key
table
)
"gsl_ran_discrete"
(((
mpointer
generator
)
:pointer
)
((
mpointer
table
)
:pointer
))
...
...
@@ -65,7 +64,7 @@
(
rng
(
make-random-number-generator
+mt19937+
0
)))
(
loop
for
i
from
0
to
10
collect
(
sample
rng
'
discrete
:table
table
)))
(
sample
rng
:
discrete
:table
table
)))
(
let*
((
probabilities
#
m
(
0.25d0
0.5d0
0.25d0
))
(
table
(
make-discrete-random
probabilities
)))
(
discrete-pdf
1
table
)))
random/exponential-power.lisp
View file @
e522dde8
;; Exponential power distribution
;; Liam Healy, Sat Sep 30 2006
;; Time-stamp: <20
09-12-2
7 10:
00
:0
2
EST exponential-power.lisp>
;; Time-stamp: <20
10-01-1
7 10:
11
:0
3
EST exponential-power.lisp>
;;
;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
...
...
@@ -22,9 +22,8 @@
;;; /usr/include/gsl/gsl_randist.h
(
export
'exponential-power
)
(
defmfun
sample
((
generator
random-number-generator
)
(
type
(
eql
'
exponential-power
))
((
generator
random-number-generator
)
(
type
(
eql
:
exponential-power
))
&key
a
b
)
"gsl_ran_exppow"
(((
mpointer
generator
)
:pointer
)
(
a
:double
)
(
b
:double
))
...
...
@@ -45,7 +44,7 @@
:documentation
; FDL
"The probability density p(x) at x
for an exponential power distribution with scale parameter a
and exponent b, using the formula given for #'exponential-power."
)
and exponent b, using the formula given for #'
sample :
exponential-power."
)
(
defmfun
exponential-power-P
(
x
a
b
)
"gsl_cdf_exppow_P"
((
x
:double
)
(
a
:double
)
(
b
:double
))
...
...
@@ -68,7 +67,7 @@
(
let
((
rng
(
make-random-number-generator
+mt19937+
0
)))
(
loop
for
i
from
0
to
10
collect
(
sample
rng
'
exponential-power
:a
1.0d0
:b
2.0d0
)))
(
sample
rng
:
exponential-power
:a
1.0d0
:b
2.0d0
)))
(
exponential-power-pdf
0.0d0
1.0d0
2.0d0
)
(
exponential-power-P
1.0d0
1.0d0
2.0d0
)
(
exponential-power-Q
1.0d0
1.0d0
2.0d0
))
random/exponential.lisp
View file @
e522dde8
;; Exponential distribution
;; Liam Healy, Sat Sep 2 2006 - 19:04
;; Time-stamp: <20
09-12-2
7 10:
00
:0
2
EST exponential.lisp>
;; Time-stamp: <20
10-01-1
7 10:
12
:0
0
EST exponential.lisp>
;;
;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
...
...
@@ -23,9 +23,8 @@
;;; /usr/include/gsl/gsl_randist.h
;;; /usr/include/gsl/gsl_cdf.h
(
export
'exponential
)
(
defmfun
sample
((
generator
random-number-generator
)
(
type
(
eql
'
exponential
))
((
generator
random-number-generator
)
(
type
(
eql
:
exponential
))
&key
mu
)
"gsl_ran_exponential"
(((
mpointer
generator
)
:pointer
)
(
mu
:double
))
...
...
@@ -43,7 +42,7 @@
:documentation
; FDL
"The probability density p(x) at x
for an exponential distribution with mean mu, using the formula
given for exponential."
)
given for
#'sample :
exponential."
)
(
defmfun
exponential-P
(
x
mu
)
"gsl_cdf_exponential_P"
((
x
:double
)
(
mu
:double
))
...
...
@@ -78,7 +77,7 @@
(
let
((
rng
(
make-random-number-generator
+mt19937+
0
)))
(
loop
for
i
from
0
to
10
collect
(
sample
rng
'
exponential
:mu
10.0d0
)))
(
sample
rng
:
exponential
:mu
10.0d0
)))
(
exponential-pdf
0.0d0
10.0d0
)
(
exponential-p
1.0d0
2.0d0
)
(
exponential-q
1.0d0
2.0d0
)
...
...
random/fdist.lisp
View file @
e522dde8
;; Fdist distribution
;; Liam Healy, Sat Sep 30 2006
;; Time-stamp: <20
09-12-27 10:00:01
EST fdist.lisp>
;; Time-stamp: <20
10-01-17 10:12:32
EST fdist.lisp>
;;
;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
...
...
@@ -23,9 +23,8 @@
;;; /usr/include/gsl/gsl_randist.h
;;; /usr/include/gsl/gsl_cdf.h
(
export
'fdist
)
(
defmfun
sample
((
generator
random-number-generator
)
(
type
(
eql
'
fdist
))
&key
nu1
nu2
)
((
generator
random-number-generator
)
(
type
(
eql
:
fdist
))
&key
nu1
nu2
)
"gsl_ran_fdist"
(((
mpointer
generator
)
:pointer
)
(
nu1
:double
)
(
nu2
:double
))
:definition
:method
...
...
@@ -46,7 +45,7 @@
:documentation
; FDL
"The probability density p(x) at x
for an F-distribution with nu1 and nu2 degrees of freedom,
using the formula given #'fdist."
)
using the formula given #'
sample :
fdist."
)
(
defmfun
fdist-P
(
x
nu1
nu2
)
"gsl_cdf_fdist_P"
((
x
:double
)
(
nu1
:double
)
(
nu2
:double
))
...
...
@@ -85,7 +84,7 @@
(
let
((
rng
(
make-random-number-generator
+mt19937+
0
)))
(
loop
for
i
from
0
to
10
collect
(
sample
rng
'
fdist
:nu1
1.0d0
:nu2
2.0d0
)))
(
sample
rng
:
fdist
:nu1
1.0d0
:nu2
2.0d0
)))
(
fdist-pdf
1.2d0
1.0d0
2.0d0
)
(
fdist-P
1.2d0
1.0d0
2.0d0
)
(
fdist-Q
1.2d0
1.0d0
2.0d0
)
...
...
random/flat.lisp
View file @
e522dde8
;; Flat distribution
;; Liam Healy, Oct 7 2006
;; Time-stamp: <20
09-12-27 10:00:01
EST flat.lisp>
;; Time-stamp: <20
10-01-17 10:13:12
EST flat.lisp>
;;
;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
...
...
@@ -22,9 +22,8 @@
;;; /usr/include/gsl/gsl_randist.h
(
export
'flat
)
(
defmfun
sample
((
generator
random-number-generator
)
(
type
(
eql
'
flat
))
&key
a
b
)
((
generator
random-number-generator
)
(
type
(
eql
:
flat
))
&key
a
b
)
"gsl_ran_flat"
(((
mpointer
generator
)
:pointer
)
(
a
:double
)
(
b
:double
))
:definition
:method
...
...
@@ -41,7 +40,7 @@
:documentation
; FDL
"The probability density p(x) at x
for a uniform distribution from a to b, using the formula
given for #'flat."
)
given for #'
sample :
flat."
)
(
defmfun
flat-P
(
x
a
b
)
"gsl_cdf_flat_P"
((
x
:double
)
(
a
:double
)
(
b
:double
))
...
...
@@ -76,7 +75,7 @@
(
let
((
rng
(
make-random-number-generator
+mt19937+
0
)))
(
loop
for
i
from
0
to
10
collect
(
sample
rng
'
flat
:a
1.0d0
:b
2.0d0
)))
(
sample
rng
:
flat
:a
1.0d0
:b
2.0d0
)))
(
flat-pdf
1.2d0
1.0d0
2.0d0
)
(
flat-P
1.2d0
1.0d0
2.0d0
)
(
flat-Q
1.2d0
1.0d0
2.0d0
)
...
...
random/gamma.lisp
View file @
e522dde8
;; Gamma distribution
;; Liam Healy, Sat Sep 30 2006
;; Time-stamp: <20
09-12-27 10:00:00
EST gamma.lisp>
;; Time-stamp: <20
10-01-17 10:14:35
EST gamma.lisp>
;;
;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
...
...
@@ -23,9 +23,8 @@
;;; /usr/include/gsl/gsl_randist.h
;;; /usr/include/gsl/gsl_cdf.h
(
export
'gamma
)
(
defmfun
sample
((
generator
random-number-generator
)
(
type
(
eql
'
gamma
))
&key
a
b
)
((
generator
random-number-generator
)
(
type
(
eql
:
gamma
))
&key
a
b
)
"gsl_ran_gamma"
(((
mpointer
generator
)
:pointer
)
(
a
:double
)
(
b
:double
))
:definition
:method
...
...
@@ -38,9 +37,8 @@
is known as the Erlang distribution. The variates are computed using
the algorithms from Knuth (vol 2)."
)
(
export
'gamma-mt
)
(
defmfun
sample
((
generator
random-number-generator
)
(
type
(
eql
'
gamma-mt
))
&key
a
b
)
((
generator
random-number-generator
)
(
type
(
eql
:
gamma-mt
))
&key
a
b
)
"gsl_ran_gamma_mt"
(((
mpointer
generator
)
:pointer
)
(
a
:double
)
(
b
:double
))
:definition
:method
...
...
@@ -54,7 +52,7 @@
:documentation
; FDL
"The probability density p(x) at x
for a gamma distribution with parameters a and b, using the
formula given in #'gamma."
)
formula given in #'
sample :
gamma."
)
(
defmfun
gamma-P
(
x
a
b
)
"gsl_cdf_gamma_P"
((
x
:double
)
(
a
:double
)
(
b
:double
))
...
...
@@ -89,11 +87,11 @@
(
let
((
rng
(
make-random-number-generator
+mt19937+
0
)))
(
loop
for
i
from
0
to
10
collect
(
sample
rng
'
gamma
:a
1.0d0
:b
2.0d0
)))
(
sample
rng
:
gamma
:a
1.0d0
:b
2.0d0
)))
(
let
((
rng
(
make-random-number-generator
+mt19937+
0
)))
(
loop
for
i
from
0
to
10
collect
(
sample
rng
'
gamma-mt
:a
1.0d0
:b
2.0d0
)))
(
sample
rng
:
gamma-mt
:a
1.0d0
:b
2.0d0
)))
(
gamma-pdf
0.1d0
1.0d0
2.0d0
)
(
gamma-P
0.1d0
1.0d0
2.0d0
)
(
gamma-Q
0.1d0
1.0d0
2.0d0
)
...
...
random/gaussian-bivariate.lisp
View file @
e522dde8
;; Gaussian bivariate distribution
;; Liam Healy, Sat Sep 2 2006 - 16:32
;; Time-stamp: <20
09-12-27 10:00:00
EST gaussian-bivariate.lisp>
;; Time-stamp: <20
10-01-17 10:15:54
EST gaussian-bivariate.lisp>
;;
;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
...
...
@@ -23,9 +23,8 @@
;;; /usr/include/gsl/gsl_randist.h
(
export
'gaussian-bivariate
)
(
defmfun
sample
((
generator
random-number-generator
)
(
type
(
eql
'gaussian-bivariate
))
((
generator
random-number-generator
)
(
type
(
eql
:bivariate-gaussian
))
&key
sigma-x
sigma-y
rho
)
"gsl_ran_bivariate_gaussian"
(((
mpointer
generator
)
:pointer
)
(
sigma-x
:double
)
(
sigma-y
:double
)
(
rho
:double
)
...
...
@@ -52,7 +51,7 @@
"The probability density p(x,y) at
(x,y) for a bivariate Gaussian distribution with standard
deviations sigma_x, sigma_y and correlation coefficient
rho, using the formula given for bivariate-gaussian."
)
rho, using the formula given for
#'sample :
bivariate-gaussian."
)
;;; Examples and unit test
(
save-test
gaussian-bivariate
...
...
@@ -60,7 +59,7 @@
(
loop
for
i
from
0
to
10
collect
(
sample
rng
'gaussian-bivariate
rng
:bivariate-gaussian
:sigma-x
1.0d0
:sigma-y
0.75d0
:rho
0.25d0
)))
(
bivariate-gaussian-pdf
0.25d0
0.5d0
0.25d0
0.4d0
0.2d0
))
random/gaussian-tail.lisp
View file @
e522dde8
;; Gaussian tail distribution
;; Liam Healy, Mon Aug 21 2006 - 21:52
;; Time-stamp: <20
09-12-27 10:01:43
EST gaussian-tail.lisp>
;; Time-stamp: <20
10-01-17 10:17:01
EST gaussian-tail.lisp>
;;
;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
...
...
@@ -22,9 +22,8 @@
;;; /usr/include/gsl/gsl_randist.h
(
export
'gaussian-tail
)
(
defmfun
sample
((
generator
random-number-generator
)
(
type
(
eql
'
gaussian-tail
))
((
generator
random-number-generator
)
(
type
(
eql
:
gaussian-tail
))
&key
a
sigma
)
"gsl_ran_gaussian_tail"
(((
mpointer
generator
)
:pointer
)
(
a
:double
)
(
sigma
:double
))
...
...
@@ -51,9 +50,8 @@
for a Gaussian tail distribution with standard deviation sigma and
lower limit a, using the formula given for gaussian-tail."
)
(
export
'ugaussian-tail
)
(
defmfun
sample
((
generator
random-number-generator
)
(
type
(
eql
'
ugaussian-tail
))
((
generator
random-number-generator
)
(
type
(
eql
:
ugaussian-tail
))
&key
a
)
"gsl_ran_ugaussian_tail"
(((
mpointer
generator
)
:pointer
)
(
a
:double
))
...
...
@@ -74,10 +72,10 @@
(
let
((
rng
(
make-random-number-generator
+mt19937+
0
)))
(
loop
for
i
from
0
to
10
collect
(
sample
rng
'
gaussian-tail
:a
50.0d0
:sigma
10.0d0
)))
(
sample
rng
:
gaussian-tail
:a
50.0d0
:sigma
10.0d0
)))
(
gaussian-tail-pdf
52.0d0
50.0d0
10.0d0
)
(
let
((
rng
(
make-random-number-generator
+mt19937+
0
)))
(
loop
for
i
from
0
to
10
collect
(
sample
rng
'
ugaussian-tail
:a
5.0d0
)))
(
sample
rng
:
ugaussian-tail
:a
5.0d0
)))
(
ugaussian-tail-pdf
5.2d0
5.0d0
))
random/gaussian.lisp
View file @
e522dde8
;; Gaussian distribution
;; Liam Healy, Sun Jul 16 2006 - 22:09
;; Time-stamp: <20
09-12-27 10:00:00
EST gaussian.lisp>
;; Time-stamp: <20
10-01-17 10:19:46
EST gaussian.lisp>
;;
;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
...
...
@@ -23,9 +23,8 @@
;;; /usr/include/gsl/gsl_randist.h
;;; /usr/include/gsl/gsl_cdf.h
(
export
'gaussian
)
(
defmfun
sample
((
generator
random-number-generator
)
(
type
(
eql
'
gaussian
))
((
generator
random-number-generator
)
(
type
(
eql
:
gaussian
))
&key
sigma
)
"gsl_ran_gaussian"
(((
mpointer
generator
)
:pointer
)
(
sigma
:double
))
...
...
@@ -38,7 +37,7 @@
p(x) dx = {1 \over \sqrt{2 \pi \sigma^2}} \exp (-x^2 / 2\sigma^2) dx
for x in the range -\infty to +\infty. Use the
transformation z = \mu + x on the numbers returned by
#'gaussia
n to obtain a Gaussian distribution with mean
this functio
n to obtain a Gaussian distribution with mean
mu. This function uses the Box-Mueller algorithm which requires two
calls to the random number generator r."
)
...
...
@@ -49,9 +48,8 @@
"Compute the probability density p(x) at x
for a Gaussian distribution with standard deviation sigma."
)
(
export
'gaussian-ziggurat
)
(
defmfun
sample
((
generator
random-number-generator
)
(
type
(
eql
'
gaussian-ziggurat
))
((
generator
random-number-generator
)
(
type
(
eql
:
gaussian-ziggurat
))
&key
sigma
)
"gsl_ran_gaussian_ziggurat"
(((
mpointer
generator
)
:pointer
)
(
sigma
:double
))
...
...
@@ -62,9 +60,8 @@
Marsaglia-Tsang ziggurat method. The Ziggurat algorithm
is the fastest available algorithm in most cases."
)
(
export
'gaussian-ratio-method
)
(
defmfun
sample
((
generator
random-number-generator
)
(
type
(
eql
'
gaussian-ratio-method
))
((
generator
random-number-generator
)
(
type
(
eql
:
gaussian-ratio-method
))
&key
sigma
)
"gsl_ran_gaussian_ratio_method"
(((
mpointer
generator
)
:pointer
)
(
sigma
:double
))
...
...
@@ -74,16 +71,15 @@
"Compute a Gaussian random variate using the Kinderman-Monahan-Leva
ratio method."
)
(
export
'ugaussian
)
(
defmfun
sample
((
generator
random-number-generator
)
(
type
(
eql
'
ugaussian
))
&key
)
((
generator
random-number-generator
)
(
type
(
eql
:
ugaussian
))
&key
)
"gsl_ran_ugaussian"
(((
mpointer
generator
)
:pointer
))
:definition
:method
:c-return
:double
:documentation
; FDL
"Compute results for the unit Gaussian distribution,
equivalent to the #'gaussian with a standard deviation of
one,
sigma = 1."
)
equivalent to the #'
sample :
gaussian with a standard deviation of
one,
sigma = 1."
)
(
defmfun
ugaussian-pdf
(
x
)
"gsl_ran_ugaussian_pdf"
((
x
:double
))
...
...
@@ -93,9 +89,8 @@
equivalent to the #'gaussian-pdf with a standard deviation of one,
sigma = 1."
)
(
export
'ugaussian-ratio-method
)
(
defmfun
sample
((
generator
random-number-generator
)
(
type
(
eql
'
ugaussian-ratio-method
))
((
generator
random-number-generator
)
(
type
(
eql
:
ugaussian-ratio-method
))
&key
)
"gsl_ran_ugaussian_ratio_method"
(((
mpointer
generator
)
:pointer
))
...
...
@@ -103,8 +98,8 @@
:c-return
:double
:documentation
; FDL
"Compute results for the unit Gaussian distribution,
equivalent to the #'gaussian-ration-method with a
standard
deviation of one, sigma = 1."
)
equivalent to the #'
sample :
gaussian-ration-method with a
standard
deviation of one, sigma = 1."
)
(
defmfun
gaussian-P
(
x
sigma
)
"gsl_cdf_gaussian_P"
((
x
:double
)
(
sigma
:double
))
...
...
@@ -168,12 +163,12 @@
(
let
((
rng
(
make-random-number-generator
+mt19937+
0
)))
(
loop
for
i
from
0
to
10
collect
(
sample
rng
'
gaussian
:sigma
10.0d0
)))
(
sample
rng
:
gaussian
:sigma
10.0d0
)))
(
gaussian-pdf
0.0d0
10.0d0
)
(
let
((
rng
(
make-random-number-generator
+mt19937+
0
)))
(
loop
for
i
from
0
to
10
collect
(
sample
rng
'
gaussian-ziggurat
:sigma
10.0d0
)))
(
sample
rng
:
gaussian-ziggurat
:sigma
10.0d0
)))
;; Given in examples in GSL documentation
(
ugaussian-p
2.0d0
)
(
ugaussian-q
2.0d0
)
...
...
random/generators.lisp
View file @
e522dde8
;; Generators of random numbers.
;; Liam Healy, Sat Jul 15 2006 - 14:43
;; Time-stamp: <20
09-12-2
7 10:
0
1:
42
EST generators.lisp>
;; Time-stamp: <20
10-01-1
7 10:
2
1:
31
EST generators.lisp>
;;
;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
...
...
@@ -77,8 +77,7 @@
(
:documentation
"Sample from the probability distribution."
))
(
export
'uniform
)
(
defmfun
sample
((
source
random-number-generator
)
(
type
(
eql
'uniform
))
&key
)
(
defmfun
sample
((
source
random-number-generator
)
(
type
(
eql
:uniform
))
&key
)
"gsl_rng_uniform"
(((
mpointer
source
)
:pointer
))
:definition
:method
:c-return
:double
...
...
@@ -92,8 +91,7 @@
(the maximum number of bits that can be portably represented in a single
:ulong."
)
(
export
'uniform>0
)
(
defmfun
sample
((
source
random-number-generator
)
(
type
(
eql
'uniform>0
))
&key
)
(
defmfun
sample
((
source
random-number-generator
)
(
type
(
eql
:uniform>0
))
&key
)
"gsl_rng_uniform_pos"
(((
mpointer
source
)
:pointer
))
:definition
:method
:c-return
:double
...
...
@@ -104,9 +102,8 @@
type 'uniform until a non-zero value is obtained. You can use this
function if you need to avoid a singularity at 0.0."
)
(
export
'uniform-fixnum
)
(
defmfun
sample
((
source
random-number-generator
)
(
type
(
eql
'
uniform-fixnum
))