This is the distributions Reference Manual, version 1.0.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 05:59:32 2024 GMT+0.
distributions/distributions.asd
distributions/packages.lisp
distributions/internals.lisp
distributions/generator.lisp
distributions/simple-multiplicative-congruential-generators.lisp
distributions/defs.lisp
distributions/generics.lisp
distributions/discrete.lisp
distributions/uniform.lisp
distributions/exponential.lisp
distributions/normal.lisp
distributions/log-normal.lisp
distributions/truncated-normal.lisp
distributions/t-distribution.lisp
distributions/gamma.lisp
distributions/chi-square.lisp
distributions/beta.lisp
distributions/rayleigh.lisp
distributions/bernoulli.lisp
distributions/binomial.lisp
distributions/geometric.lisp
distributions/poisson.lisp
The main system appears first, followed by any subsystem dependency.
distributions
Random numbers and distributions
Statistical distributions and related functions
Steven Nunez <steve@symbolics.tech>
(GIT https://github.com/Lisp-Stat/distributions.git)
MS-PL
The Distributions package provides a collection of probabilistic distributions and related functions including:
- Sampling from distributions
- Moments (e.g mean, variance, skewness, and kurtosis), entropy, and other properties
- Probability density/mass functions (pdf) and their logarithm (logpdf)
- Moment-generating functions and characteristic functions
- Maximum likelihood estimation
- Distribution composition and derived distributions
1.0.0
alexandria
(system).
anaphora
(system).
array-operations
(system).
cephes
(system).
num-utils
(system).
special-functions
(system).
let-plus
(system).
float-features
(system).
packages.lisp
(file).
internals.lisp
(file).
generator.lisp
(file).
simple-multiplicative-congruential-generators.lisp
(file).
defs.lisp
(file).
generics.lisp
(file).
discrete.lisp
(file).
uniform.lisp
(file).
exponential.lisp
(file).
normal.lisp
(file).
log-normal.lisp
(file).
truncated-normal.lisp
(file).
t-distribution.lisp
(file).
gamma.lisp
(file).
chi-square.lisp
(file).
beta.lisp
(file).
rayleigh.lisp
(file).
bernoulli.lisp
(file).
binomial.lisp
(file).
geometric.lisp
(file).
poisson.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
distributions/distributions.asd
distributions/packages.lisp
distributions/internals.lisp
distributions/generator.lisp
distributions/simple-multiplicative-congruential-generators.lisp
distributions/defs.lisp
distributions/generics.lisp
distributions/discrete.lisp
distributions/uniform.lisp
distributions/exponential.lisp
distributions/normal.lisp
distributions/log-normal.lisp
distributions/truncated-normal.lisp
distributions/t-distribution.lisp
distributions/gamma.lisp
distributions/chi-square.lisp
distributions/beta.lisp
distributions/rayleigh.lisp
distributions/bernoulli.lisp
distributions/binomial.lisp
distributions/geometric.lisp
distributions/poisson.lisp
distributions/internals.lisp
packages.lisp
(file).
distributions
(system).
as-float
(function).
as-float-probabilities
(function).
as-float-vector
(function).
float-vector
(type).
internal-float
(type).
maybe-ignore-constant
(macro).
try
(macro).
with-floats
(macro).
distributions/generator.lisp
internals.lisp
(file).
distributions
(system).
generator
(class).
initialize-instance
(method).
make-generator
(function).
next
(function).
%next-double-float
(function).
%next-integer
(function).
%next-single-float
(function).
*default-generator-type*
(special variable).
chunk-length
(reader method).
copy-state
(generic function).
default-seed
(reader method).
generate-seed
(function).
generate-state
(generic function).
state
(reader method).
(setf state)
(writer method).
distributions/simple-multiplicative-congruential-generators.lisp
generator.lisp
(file).
distributions
(system).
borosh13
(class).
initialize-instance
(method).
randu
(class).
transputer
(class).
waterman14
(class).
a
(reader method).
clone
(method).
generate-state
(method).
m
(reader method).
next-chunk
(method).
next-real
(method).
simple-multiplicative-congruential
(class).
distributions/defs.lisp
distributions
(system).
check-probability
(function).
define-rv
(macro).
distributions/generics.lisp
defs.lisp
(file).
distributions
(system).
nu
(generic function).
quantile
(generic function).
standard-deviation
(generic function).
copy-r-univariate
(function).
make-r-univariate
(function).
r-univariate
(structure).
r-univariate-p
(function).
s^2
(generic function).
distributions/discrete.lisp
generics.lisp
(file).
distributions
(system).
cdf
(method).
distinct-random-integers
(function).
distinct-random-integers-dense
(function).
draw
(method).
log-pdf
(method).
mean
(method).
probabilities
(method).
r-discrete
(function).
r-discrete
(structure).
variance
(method).
copy-r-discrete
(function).
make-r-discrete
(function).
r-discrete-alias
(reader).
(setf r-discrete-alias)
(writer).
r-discrete-n-float
(reader).
(setf r-discrete-n-float)
(writer).
r-discrete-p
(function).
r-discrete-prob
(reader).
(setf r-discrete-prob)
(writer).
r-discrete-probabilities
(reader).
(setf r-discrete-probabilities)
(writer).
distributions/uniform.lisp
discrete.lisp
(file).
distributions
(system).
copy-r-uniform
(function).
make-r-uniform
(function).
r-uniform-left
(reader).
(setf r-uniform-left)
(writer).
r-uniform-p
(function).
r-uniform-right
(reader).
(setf r-uniform-right)
(writer).
r-uniform-width
(reader).
(setf r-uniform-width)
(writer).
distributions/exponential.lisp
uniform.lisp
(file).
distributions
(system).
cdf
(method).
draw
(method).
draw-exponential
(function).
draw-standard-exponential
(function).
log-pdf
(method).
mean
(method).
quantile
(method).
r-exponential
(function).
r-exponential
(structure).
rate
(method).
variance
(method).
copy-r-exponential
(function).
make-r-exponential
(function).
r-exponential-p
(function).
r-exponential-rate
(reader).
(setf r-exponential-rate)
(writer).
distributions/normal.lisp
exponential.lisp
(file).
distributions
(system).
cdf
(method).
draw
(method).
draw-standard-normal
(function).
from-standard-normal
(function).
log-pdf
(method).
mean
(method).
quantile
(method).
r-normal
(function).
r-normal
(structure).
to-standard-normal
(function).
variance
(method).
+normal-log-pdf-constant+
(constant).
cdf-normal%
(function).
copy-r-normal
(function).
make-r-normal
(function).
pdf-normal%
(function).
quantile-normal%
(function).
r-normal-mean
(reader).
(setf r-normal-mean)
(writer).
r-normal-p
(function).
r-normal-sd
(reader).
(setf r-normal-sd)
(writer).
sd
(method).
distributions/log-normal.lisp
normal.lisp
(file).
distributions
(system).
cdf
(method).
draw
(method).
log-pdf
(method).
mean
(method).
quantile
(method).
r-log-normal
(function).
r-log-normal
(structure).
variance
(method).
copy-r-log-normal
(function).
make-r-log-normal
(function).
r-log-normal-log-mean
(reader).
(setf r-log-normal-log-mean)
(writer).
r-log-normal-log-sd
(reader).
(setf r-log-normal-log-sd)
(writer).
r-log-normal-p
(function).
distributions/truncated-normal.lisp
log-normal.lisp
(file).
distributions
(system).
copy-left-truncated-normal
(function).
draw-left-truncated-standard-normal
(function).
left-truncated-normal
(function).
left-truncated-normal
(structure).
left-truncated-normal-alpha
(reader).
(setf left-truncated-normal-alpha)
(writer).
left-truncated-normal-left
(reader).
(setf left-truncated-normal-left)
(writer).
left-truncated-normal-left-standardized
(reader).
(setf left-truncated-normal-left-standardized)
(writer).
left-truncated-normal-m0
(reader).
(setf left-truncated-normal-m0)
(writer).
left-truncated-normal-mu
(reader).
(setf left-truncated-normal-mu)
(writer).
left-truncated-normal-p
(function).
left-truncated-normal-sigma
(reader).
(setf left-truncated-normal-sigma)
(writer).
make-left-truncated-normal
(function).
truncated-normal-moments%
(function).
truncated-normal-optimal-alpha
(function).
distributions/t-distribution.lisp
truncated-normal.lisp
(file).
distributions
(system).
draw
(method).
draw-standard-t
(function).
mean
(method).
nu
(method).
r-t
(function).
r-t
(structure).
scale
(method).
t-scale-to-variance-coefficient
(function).
variance
(method).
copy-r-t
(function).
make-r-t
(function).
r-t-mean
(reader).
(setf r-t-mean)
(writer).
r-t-nu
(reader).
(setf r-t-nu)
(writer).
r-t-p
(function).
r-t-scale
(reader).
(setf r-t-scale)
(writer).
distributions/gamma.lisp
t-distribution.lisp
(file).
distributions
(system).
alpha
(method).
alpha
(method).
beta
(method).
beta
(method).
cdf
(method).
cdf-gamma
(function).
draw
(method).
draw
(method).
log-pdf
(method).
log-pdf
(method).
mean
(method).
mean
(method).
num=
(method).
pdf-gamma
(function).
quantile
(method).
r-gamma
(function).
r-gamma
(structure).
r-inverse-gamma
(function).
r-inverse-gamma
(structure).
variance
(method).
variance
(method).
cdf-gamma%+
(function).
copy-r-gamma
(function).
copy-r-inverse-gamma
(function).
draw-standard-gamma1
(function).
make-r-gamma
(function).
make-r-inverse-gamma
(function).
pdf-gamma%
(function).
pdf-gamma*
(function).
pdf-gamma+
(function).
r-gamma-alpha
(reader).
(setf r-gamma-alpha)
(writer).
r-gamma-beta
(reader).
(setf r-gamma-beta)
(writer).
r-gamma-p
(function).
r-inverse-gamma-alpha
(reader).
(setf r-inverse-gamma-alpha)
(writer).
r-inverse-gamma-beta
(reader).
(setf r-inverse-gamma-beta)
(writer).
r-inverse-gamma-p
(function).
standard-gamma1-d-c
(function).
distributions/chi-square.lisp
gamma.lisp
(file).
distributions
(system).
nu
(method).
nu
(method).
r-chi-square
(function).
r-inverse-chi-square
(function).
s^2
(method).
distributions/beta.lisp
chi-square.lisp
(file).
distributions
(system).
copy-r-beta
(function).
make-r-beta
(function).
r-beta-alpha
(reader).
(setf r-beta-alpha)
(writer).
r-beta-beta
(reader).
(setf r-beta-beta)
(writer).
r-beta-p
(function).
distributions/rayleigh.lisp
beta.lisp
(file).
distributions
(system).
cdf
(method).
draw
(method).
draw-rayleigh
(function).
mean
(method).
r-rayleigh
(function).
r-rayleigh
(structure).
scale
(method).
variance
(method).
copy-r-rayleigh
(function).
make-r-rayleigh
(function).
r-rayleigh-p
(function).
r-rayleigh-scale
(reader).
(setf r-rayleigh-scale)
(writer).
distributions/bernoulli.lisp
rayleigh.lisp
(file).
distributions
(system).
cdf
(method).
draw
(method).
draw-bernoulli
(function).
mean
(method).
r-bernoulli
(function).
r-bernoulli
(structure).
variance
(method).
copy-r-bernoulli
(function).
draw-bernoulli-bit
(function).
make-r-bernoulli
(function).
pr
(method).
r-bernoulli-p
(function).
r-bernoulli-pr
(reader).
(setf r-bernoulli-pr)
(writer).
distributions/binomial.lisp
bernoulli.lisp
(file).
distributions
(system).
draw
(method).
draw-binomial
(function).
mean
(method).
r-binomial
(function).
r-binomial
(structure).
variance
(method).
copy-r-binomial
(function).
make-r-binomial
(function).
n
(method).
pr
(method).
r-binomial-n
(reader).
(setf r-binomial-n)
(writer).
r-binomial-p
(function).
r-binomial-pr
(reader).
(setf r-binomial-pr)
(writer).
distributions/geometric.lisp
binomial.lisp
(file).
distributions
(system).
draw
(method).
draw-geometric
(function).
mean
(method).
r-geometric
(function).
r-geometric
(structure).
variance
(method).
copy-r-geometric
(function).
make-r-geometric
(function).
pr
(method).
r-geometric-p
(function).
r-geometric-pr
(reader).
(setf r-geometric-pr)
(writer).
distributions/poisson.lisp
geometric.lisp
(file).
distributions
(system).
draw-poisson
(function).
Packages are listed by definition order.
distributions
alexandria
.
anaphora
.
common-lisp
.
distributions.internals
.
let-plus
.
num-utils.elementwise
.
num-utils.matrix
.
num-utils.num=
.
special-functions
.
alpha
(generic function).
beta
(generic function).
borosh13
(class).
cdf
(generic function).
cdf-gamma
(function).
distinct-random-integers
(function).
distinct-random-integers-dense
(function).
draw
(generic function).
draw-bernoulli
(function).
draw-binomial
(function).
draw-exponential
(function).
draw-geometric
(function).
draw-poisson
(function).
draw-rayleigh
(function).
draw-standard-exponential
(function).
draw-standard-normal
(function).
draw-standard-t
(function).
draw-uniform
(function).
from-standard-normal
(function).
generator
(generic function).
generator
(class).
left
(generic function).
log-pdf
(generic function).
make-generator
(function).
mean
(generic function).
next
(function).
nu
(generic function).
pdf
(function).
pdf-gamma
(function).
probabilities
(generic function).
quantile
(generic function).
r-bernoulli
(function).
r-bernoulli
(structure).
r-beta
(function).
r-beta
(structure).
r-binomial
(function).
r-binomial
(structure).
r-chi-square
(function).
r-discrete
(function).
r-discrete
(structure).
r-exponential
(function).
r-exponential
(structure).
r-gamma
(function).
r-gamma
(structure).
r-geometric
(function).
r-geometric
(structure).
r-inverse-chi-square
(function).
r-inverse-gamma
(function).
r-inverse-gamma
(structure).
r-log-normal
(function).
r-log-normal
(structure).
r-normal
(function).
r-normal
(structure).
r-rayleigh
(function).
r-rayleigh
(structure).
r-t
(function).
r-t
(structure).
r-truncated-normal
(function).
r-uniform
(function).
r-uniform
(structure).
randu
(class).
rate
(generic function).
right
(generic function).
scale
(generic function).
standard-deviation
(generic function).
t-scale-to-variance-coefficient
(function).
to-standard-normal
(function).
transputer
(class).
variance
(generic function).
waterman14
(class).
%next-double-float
(function).
%next-integer
(function).
%next-single-float
(function).
*default-generator-type*
(special variable).
+normal-log-pdf-constant+
(constant).
a
(generic reader).
cdf-gamma%+
(function).
cdf-normal%
(function).
check-probability
(function).
chunk-length
(generic reader).
clone
(generic function).
copy-left-truncated-normal
(function).
copy-r-bernoulli
(function).
copy-r-beta
(function).
copy-r-binomial
(function).
copy-r-discrete
(function).
copy-r-exponential
(function).
copy-r-gamma
(function).
copy-r-geometric
(function).
copy-r-inverse-gamma
(function).
copy-r-log-normal
(function).
copy-r-normal
(function).
copy-r-rayleigh
(function).
copy-r-t
(function).
copy-r-uniform
(function).
copy-r-univariate
(function).
copy-state
(generic function).
default-seed
(generic reader).
define-rv
(macro).
draw-bernoulli-bit
(function).
draw-left-truncated-standard-normal
(function).
draw-standard-gamma1
(function).
generate-seed
(function).
generate-state
(generic function).
left-truncated-normal
(function).
left-truncated-normal
(structure).
left-truncated-normal-alpha
(reader).
(setf left-truncated-normal-alpha)
(writer).
left-truncated-normal-left
(reader).
(setf left-truncated-normal-left)
(writer).
left-truncated-normal-left-standardized
(reader).
(setf left-truncated-normal-left-standardized)
(writer).
left-truncated-normal-m0
(reader).
(setf left-truncated-normal-m0)
(writer).
left-truncated-normal-mu
(reader).
(setf left-truncated-normal-mu)
(writer).
left-truncated-normal-p
(function).
left-truncated-normal-sigma
(reader).
(setf left-truncated-normal-sigma)
(writer).
m
(generic reader).
make-left-truncated-normal
(function).
make-r-bernoulli
(function).
make-r-beta
(function).
make-r-binomial
(function).
make-r-discrete
(function).
make-r-exponential
(function).
make-r-gamma
(function).
make-r-geometric
(function).
make-r-inverse-gamma
(function).
make-r-log-normal
(function).
make-r-normal
(function).
make-r-rayleigh
(function).
make-r-t
(function).
make-r-uniform
(function).
make-r-univariate
(function).
n
(generic function).
next-chunk
(generic function).
next-real
(generic function).
pdf-gamma%
(function).
pdf-gamma*
(function).
pdf-gamma+
(function).
pdf-normal%
(function).
pr
(generic function).
quantile-normal%
(function).
r-bernoulli-p
(function).
r-bernoulli-pr
(reader).
(setf r-bernoulli-pr)
(writer).
r-beta-alpha
(reader).
(setf r-beta-alpha)
(writer).
r-beta-beta
(reader).
(setf r-beta-beta)
(writer).
r-beta-p
(function).
r-binomial-n
(reader).
(setf r-binomial-n)
(writer).
r-binomial-p
(function).
r-binomial-pr
(reader).
(setf r-binomial-pr)
(writer).
r-discrete-alias
(reader).
(setf r-discrete-alias)
(writer).
r-discrete-n-float
(reader).
(setf r-discrete-n-float)
(writer).
r-discrete-p
(function).
r-discrete-prob
(reader).
(setf r-discrete-prob)
(writer).
r-discrete-probabilities
(reader).
(setf r-discrete-probabilities)
(writer).
r-exponential-p
(function).
r-exponential-rate
(reader).
(setf r-exponential-rate)
(writer).
r-gamma-alpha
(reader).
(setf r-gamma-alpha)
(writer).
r-gamma-beta
(reader).
(setf r-gamma-beta)
(writer).
r-gamma-p
(function).
r-geometric-p
(function).
r-geometric-pr
(reader).
(setf r-geometric-pr)
(writer).
r-inverse-gamma-alpha
(reader).
(setf r-inverse-gamma-alpha)
(writer).
r-inverse-gamma-beta
(reader).
(setf r-inverse-gamma-beta)
(writer).
r-inverse-gamma-p
(function).
r-log-normal-log-mean
(reader).
(setf r-log-normal-log-mean)
(writer).
r-log-normal-log-sd
(reader).
(setf r-log-normal-log-sd)
(writer).
r-log-normal-p
(function).
r-normal-mean
(reader).
(setf r-normal-mean)
(writer).
r-normal-p
(function).
r-normal-sd
(reader).
(setf r-normal-sd)
(writer).
r-rayleigh-p
(function).
r-rayleigh-scale
(reader).
(setf r-rayleigh-scale)
(writer).
r-t-mean
(reader).
(setf r-t-mean)
(writer).
r-t-nu
(reader).
(setf r-t-nu)
(writer).
r-t-p
(function).
r-t-scale
(reader).
(setf r-t-scale)
(writer).
r-uniform-left
(reader).
(setf r-uniform-left)
(writer).
r-uniform-p
(function).
r-uniform-right
(reader).
(setf r-uniform-right)
(writer).
r-uniform-width
(reader).
(setf r-uniform-width)
(writer).
r-univariate
(structure).
r-univariate-p
(function).
s^2
(generic function).
sd
(generic function).
simple-multiplicative-congruential
(class).
standard-gamma1-d-c
(function).
state
(generic reader).
(setf state)
(generic writer).
truncated-normal-moments%
(function).
truncated-normal-optimal-alpha
(function).
distributions.internals
alexandria
.
common-lisp
.
let-plus
.
as-float
(function).
as-float-probabilities
(function).
as-float-vector
(function).
float-vector
(type).
internal-float
(type).
maybe-ignore-constant
(macro).
try
(macro).
with-floats
(macro).
Definitions are sorted by export status, category, package, and then by lexicographic order.
Handle a constant that is calculated only when IGNORE-CONSTANT? is NIL and VALUE is not negative infinity (represented by NIL).
Evaluate bindings (expanding into LET+, so all features can be used) until condition is satisfied, then return value.
Rebind each variable, coerced to the internal float type used by DISTRIBUTIONS.
Return the argument coerced to the DISTRIBUTIONS library’s internal float type.
Normalize vector as probabilities, assert that all are positive, return them as a VECTOR-DOUBLE-FLOAT. Vector is always copied.
Return VECTOR converted to another vector with elements converted to INTERNAL-FLOAT if necessary. When COPY?, the vector is always copied.
CDF of Gamma with parameterisation like that of R pgamma
Return a vector of COUNT distinct random integers, in increasing order, drawn from the uniform discrete distribution on {0 , ..., limit-1}.
Implementation of DISTINCT-RANDOM-INTEGERS when count/limit is (relatively) high. Implements algorithm S from @cite{taocp3}, p 142.
Return T with probability p, otherwise NIL. Rationals are handled exactly.
Return the number of successes out of N Bernoulli trials with probability of success P.
Return a random variable from the Exponential(rate) distribution which has density rate*exp(-rate*x) for x>=0 and 0 for x<0. rate > 0.
Return the number of Bernoulli trials, with probability of success P, that were needed to reach the first success. This is >= 1.
Return the number of events that occur with probability LAMDA. The algorithm is from Donald E. Knuth (1969). Seminumerical Algorithms. The Art of Computer Programming, Volume 2. Addison Wesley. WARNING: It’s simple but only linear in the return value K and is numerically unstable for large LAMDA.
Return a random variable from the Rayleigh(scale) distribution, where scale > 0 and density x * exp(-x^2 / (2 scale^2)) / scale^2 for x>=0 and 0 for x<0.
Return a random variable from the Exponential(1) distribution, which has density exp(-x) for x>=0 and 0 for x<0.
Draw a random number from N(0,1).
Draw a standard T random variate, with NU degrees of freedom.
Return a random variable from the uniform distribution between LEFT and RIGHT. It’s type is the same as that of (- LEFT RIGHT).
Scale x from standard normal.
Make a random number generator object. SEED can be any of NIL, T, an other generator, an integer, or any type of seed that a generator of type TYPE supports:
- NIL: the generator’s STD-SEED is used;
- T: a random seed is used;
- a generator: a clone is returned;
- otherwise: SEED is used as depends on the generator.
Generates a uniformly distributed pseudo-random number greater than or equal to zero and less than LIMIT. RNG, if supplied, is the random generator to use.
Probability distribution function of RANDOM-VARIABLE at X. See LOG-PDF for the semantics of IGNORE-CONSTANT?.
Return the probability density function of a gamma distribution with shape a>0, scale b>0 Returns: x^(a-1)*exp(-x/b)/gamma(a)/b^a, x>0
Chi-square distribution with NU degrees of freedom.
Generalized inverse chi-square distribution. Reparametrized to INVERSE-GAMMA.
Truncated normal distribution. If LEFT or RIGHT is NIL, it corresponds to -/+ infinity.
Return the coefficient that multiplies the Sigma matrix or the squared scale to get the variance of a (multivariate) Student-T distribution. Also checks that nu > 2, ie the variance is defined.
Scale x to standard normal.
r-inverse-gamma
)) ¶r-inverse-gamma
)) ¶Cumulative distribution function of RANDOM-VARIABLE at X.
r-bernoulli
) x) ¶r-rayleigh
) x) ¶left-truncated-normal
) x) ¶r-log-normal
) x) ¶r-exponential
) x) ¶r-discrete
) i) ¶Draw random variates. Can also be used on generators.
r-geometric
) &key rng) ¶r-binomial
) &key rng) ¶r-bernoulli
) &key rng) ¶r-rayleigh
) &key rng) ¶r-inverse-gamma
) &key rng) ¶left-truncated-normal
) &key rng) ¶r-log-normal
) &key rng) ¶r-exponential
) &key rng) ¶r-discrete
) &key rng) ¶function
) &key rng) ¶Return a closure that returns random draws.
Log of probability distribution function of RANDOM-VARIABLE at X. NIL corresponds to log(-infinity). When IGNORE-CONSTANT?, the result may be shifted by an arbitrary real constant that does not change between calls of the same RANDOM-VARIABLE. This may save computation, and is useful for MCMC methods, etc.
r-inverse-gamma
) x &optional ignore-constant?) ¶left-truncated-normal
) x &optional ignore-constant?) ¶r-log-normal
) x &optional ignore-constant?) ¶r-exponential
) x &optional ignore-constant?) ¶r-discrete
) i &optional ignore-constant?) ¶Mean of random variable.
r-geometric
)) ¶r-binomial
)) ¶r-bernoulli
)) ¶r-rayleigh
)) ¶r-inverse-gamma
)) ¶left-truncated-normal
)) ¶r-log-normal
)) ¶r-exponential
)) ¶r-discrete
)) ¶Return the degrees of freedom when applicable.
r-discrete
)) ¶Quantile of RANDOM-VARIABLE at Q.
left-truncated-normal
) q) ¶r-log-normal
) q) ¶r-exponential
) p) ¶r-exponential
)) ¶r-rayleigh
)) ¶Standard deviation of random variable.
r-univariate
)) ¶Variance of random variable.
r-geometric
)) ¶r-binomial
)) ¶r-bernoulli
)) ¶r-rayleigh
)) ¶r-inverse-gamma
)) ¶left-truncated-normal
)) ¶r-log-normal
)) ¶r-exponential
)) ¶r-discrete
)) ¶simple-multiplicative-congruential
) &key &allow-other-keys) ¶r-inverse-gamma
) (b2 r-inverse-gamma
) &optional tolerance3) ¶num-utils.num=
.
Bernoulli(pr) distribution, with probability PR for success and 1-PR for failure.
distributions.internals:internal-float
Beta(alpha,beta) distribution, with density proportional to x^(alpha-1)*(1-x)^(beta-1).
Binomial(pr,n) distribution, with N Bernoulli trials with probability PR for success.
Discrete probabilities.
distributions.internals:float-vector
distributions.internals:float-vector
(simple-array fixnum (*))
distributions.internals:internal-float
Exponential(rate) distribution, with density rate*exp(-rate*x) for x>=0 and 0 for x<0. rate > 0.
distributions.internals:internal-float
Gamma(alpha,beta) distribution, with density proportional to x^(alpha-1) exp(-x*beta). Alpha and beta are known as shape and inverse scale (or rate) parameters, respectively.
Geometric(pr) distribution.
distributions.internals:internal-float
Inverse-Gamma(alpha,beta) distribution, with density p(x) proportional to x^(-alpha+1) exp(-beta/x)
Log-normal distribution with location log-mean and scale log-sd.
Normal(mean,variance) distribution.
Rayleigh(scale) distribution with scale > 0 and density x * exp(-x^2 / (2 scale^2)) / scale^2 for x>=0 and 0 for x<0.
distributions.internals:internal-float
T(mean,scale,nu) random variate.
Uniform(left,right) distribution.
Donald E. Knuth’s Borosh-Niederreiter, The Art of Computer Programming, Volume 2, Third Edition, Addison-Wesley, pp 106-108.
Base class for random number generators.
All information needed by the generator to create the next chunk of random bits. This state is modified after each call to NEXT-CHUNK.
:state
The minimum value return by NEXT-CHUNK.
common-lisp
.
:min
The maximum value return by NEXT-CHUNK.
common-lisp
.
:max
The length in bits of the integer returned by NEXT-CHUNK.
This slot is read-only.
The seed used by default, when the seed is NIL.
0
This slot is read-only.
The poor IBM randu generator. Park and Miller, Random Number
Generators: Good ones are hard to find, Communications of the ACM, October 1988, Volume
31, No 10, pp 1192-1201.
INMOS Transputer Development System generator.
Donald E. Knuth’s Waterman, The Art of Computer Programming, Volume 2, Third Edition, Addison-Wesley, pp 106-108.
Normalizing constant for a standard normal PDF.
Define a random variable, abstracting from the representation. Syntax:
NAME is a symbol, and will name the class and the creation function.
CONSTRUCTOR-LAMBDA-LIST will be used to wrap the CONSTRUCTOR-FORM, which can use the locally define macro (MAKE :slot-name value1 ...) to initialize slots.
SLOTS is a list of (slot-name &key type read-only reader) slot specifications. When READER is T, SLOT-NAME is used instead, otherwise a method is defined using the given symbol.
OPTIONS is (&key documentation instance), the default instance is a gensym.
METHODS are (function-name lambda-list &body body), with (INSTANCE NAME) prepended to the lambda-list, ie the instance is accessible using INSTANCE. Also, within BODY, slots are accessible by their names.
Handle the single or double float case of RANDOM. We generate a float in [0d0, 1d0) by clobbering the mantissa of 1d0 with random bits (52 bits); this yields a number in [1d0, 2d0). Then 1d0 is subtracted.
Generates an integer greater than or equal to zero and less than LIMIT. Successive chunks are concatenated without overlap to construct integers larger than a single chunk. The return value has this property: If two integers are generated from the same RNG with LIMIT equal to 2^m and 2^n, respectively, then bit k is the same in both integers for 0 <= k < min(m,n). Each call to %NEXT-INTEGER consumes at least one chunk; bits left over from previous chunks are not re-used.
Handle the single or double float case of RANDOM. We generate a float in [0f0, 1f0) by clobbering the mantissa of 1f0 with random bits (23 bits); this yields a number in [1f0, 2f0). Then 1f0 is subtracted.
Return the cumulative gamma distribution function, shape k>0, scale θ>0
Internal function for normal CDF.
Assert that P is a probability (ie a real number between 0 and 1). When OPEN is given, it is checked that p is not 0 (:LEFT), 1 (:RIGHT), or 0/1 (:BOTH).
Draw a left truncated standard normal, using an Exp(alpha,left) distribution. LEFT is the standardized boundary, ALPHA should be calculated with TRUNCATED-NORMAL-OPTIMAL-ALPHA.
Return a standard gamma variate (beta=1) with shape parameter alpha >= 1. See Marsaglia and Tsang (2004). You should precalculate d and c using the utility function above.
Return a 64-bit random seed, based on current time.
left
.
m0
.
mu
.
Return the probability density function where:
K is the shape of the distribution
θ (theta) is the scale
X is the random variate
Direct calculation of the Probability Density of the normal distribution.
Internal function for normal quantile.
pr
.
beta
.
n
.
pr
.
prob
.
rate
.
beta
.
pr
.
beta
.
mean
.
sd
.
left
.
Return precalculated constants (values d c), useful for drawing from a gamma distribution.
N=0 gives the total mass of the truncated normal, used for normalization,
N=1 the mean, and N=2 the variance. where p(x) is the normal density. When LEFT or RIGHT are NIL, they are taken to be - or + infinity, respectively. M0 may be provided for efficiency if would be calculated multiple times. The formulas are from Jawitz (2004).
Calculate optimal exponential parameter for left-truncated normals. LEFT is the standardized boundary.
simple-multiplicative-congruential
)) ¶The multiplier of the sequence x(n+1) = A * x(n) mod M.
a
.
simple-multiplicative-congruential
)) ¶Return a deep copy of RNG. The stream of random numbers drawn from RNG and its clone should be the same (given you draw according to the same distributions).
random-state
)) ¶Return a state for a generator of RNG’s type using seed.
simple-multiplicative-congruential
) seed) ¶simple-multiplicative-congruential
)) ¶The modulo of the sequence x(n+1) = A * x(n) mod M.
m
.
r-binomial
)) ¶simple-multiplicative-congruential
)) ¶simple-multiplicative-congruential
)) ¶r-geometric
)) ¶r-binomial
)) ¶r-bernoulli
)) ¶Return the scale when applicable.
r-inverse-gamma
)) ¶Truncated normal distribution with given mu and sigma (corresponds to the mean and standard deviation in the untruncated case, respectively), on the interval [left, infinity).
distributions.internals:internal-float
distributions.internals:internal-float
distributions.internals:internal-float
distributions.internals:internal-float
distributions.internals:internal-float
distributions.internals:internal-float
Univariate distribution.
structure-object
.
A multiplicative congruential generator generates the sequence x(n+1) =
A * x(n) mod M and uses the seed as x(1). A simple multiplicative congruential generator
is a multiplicative congruential generator with M a power of 2. This allows to implement
the modulo operation as a bitwise and operation of M-1, which is also the maximum value
of a random chunk.
Jump to: | %
(
A B C D F G I L M N P Q R S T V W |
---|
Jump to: | %
(
A B C D F G I L M N P Q R S T V W |
---|
Jump to: | *
+
A B C D L M N P R S W |
---|
Jump to: | *
+
A B C D L M N P R S W |
---|
Jump to: | B C D E F G I L N P R S T U W |
---|
Jump to: | B C D E F G I L N P R S T U W |
---|