tinypp/distributions

Values

pub fn discrete_normal(
  mean: Float,
  std: Float,
  covering range: Float,
  in_steps_of resolution: Float,
) -> tinypp.Distribution(Float)

A univariate normal distribution with mean and standard deviation.

The “true” normal distribution has continuous and unbounded support, so you have to specify how you want to make this into a distribution that tinypp can hande: The resulting distribution covers the interval [-range, range] and is discretized in steps of resolution.

pub fn multivariate(
  univariate: tinypp.Distribution(a),
  n: Int,
) -> tinypp.Distribution(List(a))

Create a multivariate distribution as the n-fold product of a given univariate distribution.

Use this whenever you would like to call sample in a “loop”. That is, instead of

let xs = [1, 2, 3]
// DOES NOT WORK:
let ys = list.map(xs, fn(x) {
  use y <- sample(y_distribution)
  y
})

rather do:

let xs = [1, 2, 3]
let n = list.length(xs)
use ys <- sample(multivariate(y_distribution, n))
pub fn uniform(values: List(a)) -> tinypp.Distribution(a)

A discrete uniform distribution over the given values.

pub fn uniform_interval(
  min: Float,
  max: Float,
  in_steps_of resolution: Float,
) -> tinypp.Distribution(Float)

A uniform distribution over the given interval. Since we can only deal with discrete distributions, you have to specify a resolution with which the interval will be discretized.

Search Document