Commit e522dde8 by Liam Healy

Random number generator type symbols in keyword package

parent 4c9c711a
;; Basis splines.
;; Liam Healy 2008-02-18 14:43:20EST basis-splines.lisp
;; Time-stamp: <2009-12-27 09:42:10EST basis-splines.lisp>
;; Time-stamp: <2010-01-17 10:41:03EST 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)))))
......
;; Bernoulli distribution
;; Liam Healy, Sat Nov 25 2006 - 16:59
;; Time-stamp: <2009-12-27 10:00:04EST bernoulli.lisp>
;; Time-stamp: <2010-01-17 10:06:06EST 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))
;; Beta distribution
;; Liam Healy, Sat Sep 30 2006
;; Time-stamp: <2009-12-27 10:00:04EST beta.lisp>
;; Time-stamp: <2010-01-17 10:05:21EST 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)
......
;; Cauchy distribution
;; Liam Healy, Sat Sep 30 2006
;; Time-stamp: <2009-12-27 10:00:03EST cauchy.lisp>
;; Time-stamp: <2010-01-17 10:05:32EST 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)
......
;; Chi-squared distribution
;; Liam Healy, Sat Oct 7 2006 - 16:13
;; Time-stamp: <2009-12-27 10:00:03EST chi-squared.lisp>
;; Time-stamp: <2010-01-17 10:07:11EST 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)
......
;; Dirichlet distribution
;; Liam Healy, Sun Oct 29 2006
;; Time-stamp: <2009-12-27 10:00:02EST dirichlet.lisp>
;; Time-stamp: <2010-01-17 10:09:21EST 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))
......
;; Discrete random variables
;; Liam Healy, Sat Nov 11 2006 - 21:51
;; Time-stamp: <2009-12-27 10:00:02EST discrete.lisp>
;; Time-stamp: <2010-01-17 10:10:00EST 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)))
;; Exponential power distribution
;; Liam Healy, Sat Sep 30 2006
;; Time-stamp: <2009-12-27 10:00:02EST exponential-power.lisp>
;; Time-stamp: <2010-01-17 10:11:03EST 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))
;; Exponential distribution
;; Liam Healy, Sat Sep 2 2006 - 19:04
;; Time-stamp: <2009-12-27 10:00:02EST exponential.lisp>
;; Time-stamp: <2010-01-17 10:12:00EST 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)
......
;; Fdist distribution
;; Liam Healy, Sat Sep 30 2006
;; Time-stamp: <2009-12-27 10:00:01EST fdist.lisp>
;; Time-stamp: <2010-01-17 10:12:32EST 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)
......
;; Flat distribution
;; Liam Healy, Oct 7 2006
;; Time-stamp: <2009-12-27 10:00:01EST flat.lisp>
;; Time-stamp: <2010-01-17 10:13:12EST 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)
......
;; Gamma distribution
;; Liam Healy, Sat Sep 30 2006
;; Time-stamp: <2009-12-27 10:00:00EST gamma.lisp>
;; Time-stamp: <2010-01-17 10:14:35EST 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)
......
;; Gaussian bivariate distribution
;; Liam Healy, Sat Sep 2 2006 - 16:32
;; Time-stamp: <2009-12-27 10:00:00EST gaussian-bivariate.lisp>
;; Time-stamp: <2010-01-17 10:15:54EST 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))
;; Gaussian tail distribution
;; Liam Healy, Mon Aug 21 2006 - 21:52
;; Time-stamp: <2009-12-27 10:01:43EST gaussian-tail.lisp>
;; Time-stamp: <2010-01-17 10:17:01EST 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))
;; Gaussian distribution
;; Liam Healy, Sun Jul 16 2006 - 22:09
;; Time-stamp: <2009-12-27 10:00:00EST gaussian.lisp>
;; Time-stamp: <2010-01-17 10:19:46EST 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
#'gaussian to obtain a Gaussian distribution with mean
this function 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)
......
;; Generators of random numbers.
;; Liam Healy, Sat Jul 15 2006 - 14:43
;; Time-stamp: <2009-12-27 10:01:42EST generators.lisp>
;; Time-stamp: <2010-01-17 10:21:31EST 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))
((source random-number-generator) (type (eql :uniform-fixnum))
&key upperbound)
"gsl_rng_uniform_int"
(((mpointer source) :pointer) (upperbound :ulong))
......@@ -205,6 +202,6 @@
(let ((rng (make-random-number-generator +mt19937+ 0)))
(loop for i from 0 to 10
collect
(sample rng 'uniform-fixnum :upperbound 1000)))
(sample rng :uniform-fixnum :upperbound 1000)))
(let ((rng (make-random-number-generator *cmrg* 0)))
(loop for i from 0 to 10 collect (sample rng 'uniform))))
;; Geometric distribution
;; Liam Healy, Sat Nov 25 2006 - 16:00
;; Time-stamp: <2009-12-27 10:01:43EST geometric.lisp>
;; Time-stamp: <2010-01-17 10:22:14EST geometric.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 'geometric)
(defmfun sample
((generator random-number-generator) (type (eql 'geometric))
((generator random-number-generator) (type (eql :geometric))
&key probability)
"gsl_ran_geometric"
(((mpointer generator) :pointer) (probability :double))
......@@ -45,7 +44,7 @@
:documentation ; FDL
"The probability p(k) of obtaining k
from a geometric distribution with probability parameter p, using
the formula given in #'geometric.")
the formula given in #'sample :geometric.")
(defmfun geometric-P (k p)
"gsl_cdf_geometric_P" ((k :uint) (p :double))
......@@ -66,7 +65,7 @@
(let ((rng (make-random-number-generator +mt19937+ 0)))
(loop for i from 0 to 10
collect
(sample rng 'geometric :probability 0.4d0)))
(sample rng :geometric :probability 0.4d0)))
(geometric-pdf 2 0.4d0)
(geometric-P 2 0.4d0)
(geometric-Q 2 0.4d0))
;; The Gumbel type 1 random number distribution
;; Liam Healy, Sun Oct 29 2006
;; Time-stamp: <2009-12-27 10:01:41EST gumbel1.lisp>
;; Time-stamp: <2010-01-17 10:22:56EST gumbel1.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 'geometric)
(defmfun sample
((generator random-number-generator) (type (eql 'gumbel1)) &key a b)
((generator random-number-generator) (type (eql :gumbel1)) &key a b)
"gsl_ran_gumbel1"
(((mpointer generator) :pointer) (a :double) (b :double))
:definition :method
......@@ -42,7 +41,7 @@
:documentation ; FDL
"The probability density p(x) at x
for a Type-1 Gumbel distribution with parameters a and b,
using the formula given for #'gumbel1.")
using the formula given for #'sample :gumbel1.")
(defmfun gumbel1-P (x a b)
"gsl_cdf_gumbel1_P" ((x :double) (a :double) (b :double))
......@@ -80,7 +79,7 @@
(save-test gumbel1
(let ((rng (make-random-number-generator +mt19937+ 0)))
(loop for i from 0 to 10
collect (sample rng 'gumbel1 :a 1.0d0 :b 2.0d0)))
collect (sample rng :gumbel1 :a 1.0d0 :b 2.0d0)))
(gumbel1-pdf 0.1d0 1.0d0 2.0d0)
(gumbel1-P 0.1d0 1.0d0 2.0d0)
(gumbel1-Q 0.1d0 1.0d0 2.0d0)
......
;; The Gumbel type 2 random number distribution
;; Liam Healy, Sun Oct 29 2006