stats/dist
dist-normal
(dist-normal [mu :float sigma :float] :int)
construct a Normal(mu, sigma) distribution object.
| mu | :float mean | |
| sigma | :float standard deviation (> 0) |
:int dist handle. Free with dist-free.
(let [d (dist-normal 0.0 1.0)] (pdf d 0.0)) ; => ~0.3989
Since: ST3
dist-t
(dist-t [df :float] :int)
construct a Student t(df) distribution.
| df | :float degrees of freedom (> 0) |
:int dist handle.
Since: ST3
dist-chi2
(dist-chi2 [df :float] :int)
construct a chi-squared(df) distribution.
| df | :float degrees of freedom (> 0) |
:int dist handle.
Since: ST3
dist-f
(dist-f [df1 :float df2 :float] :int)
construct an F(df1, df2) distribution.
| df1 | :float numerator df | |
| df2 | :float denominator df |
:int dist handle.
Since: ST3
dist-uniform
(dist-uniform [a :float b :float] :int)
construct a Uniform(a, b) distribution.
| a | :float lower bound | |
| b | :float upper bound (b > a) |
:int dist handle.
Since: ST4
dist-binomial
(dist-binomial [n :int p :float] :int)
construct a Binomial(n, p) distribution.
| n | :int number of trials | |
| p | :float success probability in [0,1] |
:int dist handle.
Since: ST4
dist-poisson
(dist-poisson [lambda :float] :int)
construct a Poisson(lambda) distribution.
| lambda | :float rate parameter (> 0) |
:int dist handle.
Since: ST4
dist-exponential
(dist-exponential [rate :float] :int)
construct an Exponential(rate) distribution.
| rate | :float rate = 1/mean (> 0) |
:int dist handle.
Since: ST4
dist-beta
(dist-beta [alpha :float beta :float] :int)
construct a Beta(alpha, beta) distribution.
| alpha | :float shape1 (> 0) | |
| beta | :float shape2 (> 0) |
:int dist handle.
Since: ST4
dist-gamma
(dist-gamma [shape :float rate :float] :int)
construct a Gamma(shape, rate) distribution.
| shape | :float shape parameter (> 0) | |
| rate | :float rate = 1/scale (> 0) |
:int dist handle.
Since: ST4
dist-free
(dist-free [d :int] :void)
free a distribution object.
Since: ST3
(pdf [d :int x :float] :float)
probability density (or mass) at x.
| d | :int dist handle | |
| x | :float argument |
:float density / PMF value.
Since: ST3
cdf
(cdf [d :int x :float] :float)
cumulative distribution function P(X <= x).
| d | :int dist handle | |
| x | :float argument |
:float P(X <= x) in [0, 1].
Since: ST3
quantile
(quantile [d :int p :float] :float)
inverse CDF (quantile function).
| d | :int dist handle | |
| p | :float probability in [0, 1] |
:float x such that CDF(x) ~= p.
Since: ST3
random
(random [d :int rng :int] :float)
draw one sample from a distribution.
| d | :int dist handle | |
| rng | :int rng handle (from rng-make) |
:float one sample.
Since: ST3
random-n
(random-n [d :int rng :int n :int] :int)
draw n samples from a distribution into a float64 column.
| d | :int dist handle | |
| rng | :int rng handle | |
| n | :int number of samples |
:int new float64 column of length n. Caller frees.
Since: ST3
dnorm
(dnorm [x :float mu :float sigma :float] :float)
normal density at x.
Since: ST4
pnorm
(pnorm [x :float mu :float sigma :float] :float)
normal CDF at x.
Since: ST4
qnorm
(qnorm [p :float mu :float sigma :float] :float)
normal quantile at p.
Since: ST4
rnorm
(rnorm [rng :int n :int mu :float sigma :float] :int)
n normal samples.
Since: ST4
dt
(dt [x :float df :float] :float)
t density.
Since: ST4
pt
(pt [x :float df :float] :float)
t CDF.
Since: ST4
qt
(qt [p :float df :float] :float)
t quantile.
Since: ST4
rt
(rt [rng :int n :int df :float] :int)
n t samples.
Since: ST4
dchi2
(dchi2 [x :float df :float] :float)
chi-squared density.
Since: ST4
pchi2
(pchi2 [x :float df :float] :float)
chi-squared CDF.
Since: ST4
qchi2
(qchi2 [p :float df :float] :float)
chi-squared quantile.
Since: ST4
rchi2
(rchi2 [rng :int n :int df :float] :int)
n chi-squared samples.
Since: ST4
df-dist
(df-dist [x :float df1 :float df2 :float] :float)
F density.
Since: ST4
pf-dist
(pf-dist [x :float df1 :float df2 :float] :float)
F CDF.
Since: ST4
qf-dist
(qf-dist [p :float df1 :float df2 :float] :float)
F quantile.
Since: ST4
rf-dist
(rf-dist [rng :int n :int df1 :float df2 :float] :int)
n F samples.
Since: ST4
dunif
(dunif [x :float a :float b :float] :float)
uniform density.
Since: ST4
punif
(punif [x :float a :float b :float] :float)
uniform CDF.
Since: ST4
qunif
(qunif [p :float a :float b :float] :float)
uniform quantile.
Since: ST4
runif
(runif [rng :int n :int a :float b :float] :int)
n uniform samples.
Since: ST4
dbinom
(dbinom [x :float n :int p :float] :float)
binomial PMF.
Since: ST4
pbinom
(pbinom [x :float n :int p :float] :float)
binomial CDF.
Since: ST4
qbinom
(qbinom [p :float n :int pp :float] :float)
binomial quantile.
Since: ST4
rbinom
(rbinom [rng :int n-samp :int n-trials :int p :float] :int)
n binomial samples.
Since: ST4
dpois
(dpois [x :float lambda :float] :float)
Poisson PMF.
Since: ST4
ppois
(ppois [x :float lambda :float] :float)
Poisson CDF.
Since: ST4
qpois
(qpois [p :float lambda :float] :float)
Poisson quantile.
Since: ST4
rpois
(rpois [rng :int n :int lambda :float] :int)
n Poisson samples.
Since: ST4
dexp
(dexp [x :float rate :float] :float)
exponential density.
Since: ST4
pexp
(pexp [x :float rate :float] :float)
exponential CDF.
Since: ST4
qexp
(qexp [p :float rate :float] :float)
exponential quantile.
Since: ST4
rexp
(rexp [rng :int n :int rate :float] :int)
n exponential samples.
Since: ST4
dbeta
(dbeta [x :float alpha :float beta :float] :float)
beta density.
Since: ST4
pbeta
(pbeta [x :float alpha :float beta :float] :float)
beta CDF.
Since: ST4
qbeta
(qbeta [p :float alpha :float beta :float] :float)
beta quantile.
Since: ST4
rbeta
(rbeta [rng :int n :int alpha :float beta :float] :int)
n beta samples.
Since: ST4
dgamma
(dgamma [x :float shape :float rate :float] :float)
gamma density.
Since: ST4
pgamma
(pgamma [x :float shape :float rate :float] :float)
gamma CDF.
Since: ST4
qgamma
(qgamma [p :float shape :float rate :float] :float)
gamma quantile.
Since: ST4
rgamma
(rgamma [rng :int n :int shape :float rate :float] :int)
n gamma samples.
Since: ST4