Distribution
Distribution =
object
Defined in: distribution.ts:15
A probability distribution over the reals, fixed at construction.
Every member is resolved from the parameters once, so the shape is a plain
object rather than a class: nothing here mutates after the constructing call
returns, and mean and variance are values rather than methods because
they are properties of the parameters, not computations over an argument.
Discrete families implement the same shape — density is then a probability
mass, and quantile the generalised inverse (the smallest outcome whose
cumulative probability reaches the argument).
Properties
Section titled “Properties”cdf: (
x) =>number
Defined in: distribution.ts:30
Probability of drawing a value at or below x.
Parameters
Section titled “Parameters”number
Point of evaluation.
Returns
Section titled “Returns”number
P(X ≤ x), in [0, 1].
density
Section titled “density”density: (
x) =>number
Defined in: distribution.ts:22
Probability density at x, or probability mass for a discrete family.
Parameters
Section titled “Parameters”number
Point of evaluation.
Returns
Section titled “Returns”number
The density or mass; 0 outside the support.
mean:
number
Defined in: distribution.ts:63
Expected value, or NaN where the family has none.
quantile
Section titled “quantile”quantile: (
probability) =>number
Defined in: distribution.ts:51
The value at which the cumulative probability reaches probability.
Parameters
Section titled “Parameters”probability
Section titled “probability”number
Probability in [0, 1].
Returns
Section titled “Returns”number
The quantile.
Throws
Section titled “Throws”When probability is outside [0, 1].
sample
Section titled “sample”sample: (
random?) =>number
Defined in: distribution.ts:60
One draw from the distribution.
Parameters
Section titled “Parameters”random?
Section titled “random?”RandomFn | null
Uniform source over [0, 1). Defaults to Math.random; pass
a seeded generator from @ac-kit/math-random for a reproducible draw.
Returns
Section titled “Returns”number
The drawn value.
survival
Section titled “survival”survival: (
x) =>number
Defined in: distribution.ts:42
Probability of drawing a value above x.
Not a convenience over 1 - cdf(x), and the reason this member exists at
all: a tail of 1e-20 is exactly 0 once computed that way, and a tail is
precisely what a p-value is. Each family computes it directly.
Parameters
Section titled “Parameters”number
Point of evaluation.
Returns
Section titled “Returns”number
P(X > x), in [0, 1].
variance
Section titled “variance”variance:
number
Defined in: distribution.ts:66
Variance, or NaN where the family has none.