Primitive Probability Distributions

Hakaru comes with a small set of primitive probability distributions.

normal(mean. real, standard_deviation. prob): measure(real)

univariate Normal (Gaussian) distribution -

uniform(low. real, high. real): measure(real)

Uniform distribution is a continuous univariate distribution defined from low to high -

gamma(shape. prob, scale. prob): measure(prob)

Gamma distribution with shape and scale parameterization -

beta(a. prob, b. prob): measure(prob)

Beta distribution -

poisson(l. prob): measure(nat)

Poisson distribution -

categorical(v. array(prob)): measure(nat)

Categorical distribution -

dirac(x. a): measure(a)

Dirac distribution -

The Dirac distribution appears often enough, that we have given an additional keyword in our language for it: return. The following programs are equivalent.

dirac(3)

return 3


lebesgue(low. real, high.real): measure(real)

the distribution constant between low and high and zero elsewhere. high must be at least low. -

weight(x. prob, m. measure(a)): measure(a)

a m distribution, reweighted by x -

reject: measure(a)

The distribution over the empty set -

Finally, we have a binary choice operator <|>, which takes two distributions, and returns an unnormalized distribution which returns one or the other. For example, to get a distribution which where with probability 0.5 draws from a uniform(0,1), and probability 0.5 draws from uniform(5,6).

weight(0.5, uniform(0,1)) <|>
weight(0.5, uniform(5,6))