Skip to content

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).

cdf: (x) => number

Defined in: distribution.ts:30

Probability of drawing a value at or below x.

number

Point of evaluation.

number

P(X ≤ x), in [0, 1].


density: (x) => number

Defined in: distribution.ts:22

Probability density at x, or probability mass for a discrete family.

number

Point of evaluation.

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: (probability) => number

Defined in: distribution.ts:51

The value at which the cumulative probability reaches probability.

number

Probability in [0, 1].

number

The quantile.

When probability is outside [0, 1].


sample: (random?) => number

Defined in: distribution.ts:60

One draw from the distribution.

RandomFn | null

Uniform source over [0, 1). Defaults to Math.random; pass a seeded generator from @ac-kit/math-random for a reproducible draw.

number

The drawn value.


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.

number

Point of evaluation.

number

P(X > x), in [0, 1].


variance: number

Defined in: distribution.ts:66

Variance, or NaN where the family has none.