Stability | experimental |
---|---|
Maintainer | Patrick Perry <patperry@stanford.edu> |
Random number distributions. Functions for generating random variates and computing their probability distributions.
- gaussianPdf :: Double -> Double -> Double
- gaussianP :: Double -> Double -> Double
- gaussianQ :: Double -> Double -> Double
- gaussianPInv :: Double -> Double -> Double
- gaussianQInv :: Double -> Double -> Double
- getGaussian :: RNG -> Double -> IO Double
- getGaussianZiggurat :: RNG -> Double -> IO Double
- getGaussianRatioMethod :: RNG -> Double -> IO Double
- ugaussianPdf :: Double -> Double
- ugaussianP :: Double -> Double
- ugaussianQ :: Double -> Double
- ugaussianPInv :: Double -> Double
- ugaussianQInv :: Double -> Double
- getUGaussian :: RNG -> IO Double
- getUGaussianRatioMethod :: RNG -> IO Double
- flatPdf :: Double -> Double -> Double -> Double
- flatP :: Double -> Double -> Double -> Double
- flatQ :: Double -> Double -> Double -> Double
- flatPInv :: Double -> Double -> Double -> Double
- flatQInv :: Double -> Double -> Double -> Double
- getFlat :: RNG -> Double -> Double -> IO Double
- exponentialPdf :: Double -> Double -> Double
- exponentialP :: Double -> Double -> Double
- exponentialQ :: Double -> Double -> Double
- exponentialPInv :: Double -> Double -> Double
- exponentialQInv :: Double -> Double -> Double
- getExponential :: RNG -> Double -> IO Double
- getLevy :: RNG -> Double -> Double -> IO Double
- getLevySkew :: RNG -> Double -> Double -> Double -> IO Double
- poissonPdf :: Int -> Double -> Double
- poissonP :: Int -> Double -> Double
- poissonQ :: Int -> Double -> Double
- getPoisson :: RNG -> Double -> IO Int
- getCauchy :: RNG -> Double -> IO Double
- cauchyPdf :: Double -> Double -> Double
- cauchyP :: Double -> Double -> Double
- cauchyQ :: Double -> Double -> Double
- cauchyPInv :: Double -> Double -> Double
- cauchyQInv :: Double -> Double -> Double
The Gaussian Distribution
General
gaussianPdf :: Double -> Double -> DoubleSource
gaussianPdf x sigma
computes the probabililty density p(x) for
a Gaussian distribution with mean 0
and standard deviation sigma
.
gaussianP :: Double -> Double -> DoubleSource
gaussianP x sigma
computes the cumulative distribution function P(x) for
a Gaussian distribution with mean 0
and standard deviation sigma
.
gaussianQ :: Double -> Double -> DoubleSource
gaussianQ x sigma
computes the cumulative distribution function Q(x) for
a Gaussian distribution with mean 0
and standard deviation sigma
.
gaussianPInv :: Double -> Double -> DoubleSource
gaussianPInv p sigma
computes the inverse of the cumulative distribution
function of a Gaussian distribution with mean 0
and standard deviation
sigma
. It returns x
such that P(x) = p
.
gaussianQInv :: Double -> Double -> DoubleSource
gaussianPInv q sigma
computes the inverse of the cumulative distribution
function of a Gaussian distribution with mean 0
and standard deviation
sigma
. It returns x
such that Q(x) = q
.
getGaussian :: RNG -> Double -> IO DoubleSource
getGaussian r sigma
gets a normal random variable with mean
0
and standard deviation sigma
.
This uses the Box-Mueller algorithm.
getGaussianZiggurat :: RNG -> Double -> IO DoubleSource
getGaussianZiggurat r sigma
gets a normal random variable with mean
0
and standard deviation sigma
.
This uses the Marsaglia-Tsang ziggurat algorithm.
getGaussianRatioMethod :: RNG -> Double -> IO DoubleSource
getGaussianRatioMethod r sigma
gets a normal random variable with mean
0
and standard deviation sigma
.
This uses the Kinderman-Monahan-Leva ratio method.
Unit Variance
ugaussianPdf :: Double -> DoubleSource
ugaussianPdf x
computes the probabililty density p(x) for
a Gaussian distribution with mean 0
and standard deviation 1
.
ugaussianP :: Double -> DoubleSource
ugaussianP x
computes the cumulative distribution function P(x) for
a Gaussian distribution with mean 0
and standard deviation 1
.
ugaussianQ :: Double -> DoubleSource
ugaussianQ x
computes the cumulative distribution function Q(x) for
a Gaussian distribution with mean 0
and standard deviation 1
.
ugaussianPInv :: Double -> DoubleSource
ugaussianPInv p
computes the inverse of the cumulative distribution
function of a Gaussian distribution with mean 0
and standard deviation
1
. It returns x
such that P(x) = p
.
ugaussianQInv :: Double -> DoubleSource
ugaussianPInv q
computes the inverse of the cumulative distribution
function of a Gaussian distribution with mean 0
and standard deviation
1
. It returns x
such that Q(x) = q
.
getUGaussian :: RNG -> IO DoubleSource
getUGaussian r
gets a normal random variable with mean
0
and standard deviation 1
.
This uses the Box-Mueller algorithm.
getUGaussianRatioMethod :: RNG -> IO DoubleSource
getUGaussianRatioMethod r
gets a normal random variable with mean
0
and standard deviation 1
.
This uses the Kinderman-Monahan-Leva ratio method.
The Flat (Uniform) Distribution
flatPdf :: Double -> Double -> Double -> DoubleSource
flatPdf x a b
computes the probability density p(x)
at x
for
a uniform distribution from a
to b
.
flatP :: Double -> Double -> Double -> DoubleSource
flatP x a b
computes the cumulative distribution function P(x)
.
flatQ :: Double -> Double -> Double -> DoubleSource
flatQ x a b
computes the cumulative distribution function Q(x)
.
flatPInv :: Double -> Double -> Double -> DoubleSource
flatPInv p a b
computes the inverse of the cumulative distribution
and returns x
so that function P(x) = p
.
flatQInv :: Double -> Double -> Double -> DoubleSource
flatQInv q a b
computes the inverse of the cumulative distribution
and returns x
so that function Q(x) = q
.
getFlat :: RNG -> Double -> Double -> IO DoubleSource
getFlat r a b
gets a value uniformly chosen in [a,b)
.
The Exponential Distribution
exponentialPdf :: Double -> Double -> DoubleSource
exponentialPdf x mu
computes the density at x
of an exponential
with mean mu
.
exponentialP :: Double -> Double -> DoubleSource
exponentialQ :: Double -> Double -> DoubleSource
exponentialPInv :: Double -> Double -> DoubleSource
exponentialQInv :: Double -> Double -> DoubleSource
getExponential :: RNG -> Double -> IO DoubleSource
getExponential r mu
gets a random exponential with mean mu
.
The Levy alpha-Stable Distributions
getLevy :: RNG -> Double -> Double -> IO DoubleSource
getLevy r c alpha
gets a variate from the Levy symmetric stable
distribution with scale c
and exponent alpha
. The algorithm only
works for 0 <= alpha <= 2
.
getLevySkew :: RNG -> Double -> Double -> Double -> IO DoubleSource
getLevySkew r c alpha beta
gets a variate from the Levy skew stable
distribution with scale c
, exponent alpha
, and skewness parameter
beta
. The skewness parameter must lie in the range [-1,1]
. The
algorithm only works for 0 <= alpha <= 2
.
The Poisson Distribution
poissonPdf :: Int -> Double -> DoubleSource
poissonPdf k mu
evaluates the probability density p(k)
at k
for
a Poisson distribution with mean mu
.
poissonP :: Int -> Double -> DoubleSource
poissonP k mu
evaluates the cumulative distribution function P(k)
at k
for a Poisson distribution with mean mu
.
poissonQ :: Int -> Double -> DoubleSource
poissonQ k mu
evaluates the cumulative distribution function Q(k)
at k
for a Poisson distribution with mean mu
.
getPoisson :: RNG -> Double -> IO IntSource
getPoisson r mu
gets a poisson random variable with mean mu
.
The Cauchy Distribution
cauchyPdf :: Double -> Double -> DoubleSource
cauchyPdf x a
evaluates the probability density p(x)
at x
for a Cauchy distribution with scale parameter a
. The density
is given by p(x) dx = { 1 over api (1 + (x/a^2)) } dx
.
cauchyPInv :: Double -> Double -> DoubleSource
cauchyQInv :: Double -> Double -> DoubleSource