Interface

Liknorm machine

LIKNORM_API void liknorm_integrate(struct LikNormMachine * machine, double * log_zeroth, double * mean, double * variance)

Perform numerical integration.

Parameters
  • machine: Machine to perform integration.

  • log_zeroth: Zeroth moment.

  • log_mean: First moment of the normalized distribution.

  • log_variance: Variance of the normalized distribution.

LIKNORM_API void liknorm_destroy_machine(struct LikNormMachine * machine)

Destroy a Machine instance.

Parameters
  • machine: Machine to be destroyed. Always call it before exiting your program, otherwise it will leak memory.

Prior

LIKNORM_API void liknorm_set_prior(struct LikNormMachine * machine, double tau, double eta)

Set the natural parameters of Normal prior.

Parameters
  • machine: Machine to perform integration.

  • tau: It equals to σ⁻².

  • eta: It equals to μσ⁻².

Bernoulli

LIKNORM_API void liknorm_set_bernoulli(struct LikNormMachine * machine, double k)

Bernoulli distribution.

It is the discrete probability distribution of a random variable which takes the value 1 with probability p and the value 0 with probability 1 p. (Wikipedia.)

Parameters
  • machine: Liknorm handler.

  • k: Number of successes.

Binomial

LIKNORM_API void liknorm_set_binomial(struct LikNormMachine * machine, double k, double n)

Binomial distribution.

It is the discrete probability distribution of the number of successes k in a sequence of n independent experiments. (Wikipedia.) The probability mass function is given by:

Binom(k, n) pᵏ (1 - p)ⁿ⁻ᵏ,

for which Binom(m, n) = n! / (m! (n - m)!).

Parameters
  • machine: Liknorm handler.

  • k: Number of successes.

  • n: Number of trials.

Gamma

LIKNORM_API void liknorm_set_gamma(struct LikNormMachine * machine, double x, double a)

Gamma distribution.

A gamma distribution is a general type of statistical distribution that is related to the beta distribution and arises naturally in processes for which the waiting times between Poisson distributed events are relevant. (Wolfram.)

Parameters
  • machine: Liknorm handler.

  • x: Waiting time.

  • a: Shape parameter α.

Geometric

LIKNORM_API void liknorm_set_geometric(struct LikNormMachine * machine, double x)

Geometric distribution.

Parameters
  • machine: Liknorm handler.

  • x: Number of trials to success.

Negative binomial

LIKNORM_API void liknorm_set_nbinomial(struct LikNormMachine * machine, double k, double r)

Negative binomial distribution.

It is a discrete probability distribution of the number of successes in a sequence of independent and identically distributed Bernoulli trials before a specified (non-random) number of failures (denoted r) occurs. (Wikipedia.) Let k be the number of successes. The probability mass function is given by:

Binom(k, k + r - 1) pᵏ (1 - p)ʳ,

for which Binom(m, n) = n! / (m! (n - m)!).

Parameters
  • machine: Liknorm handler.

  • k: Number of successes.

  • r: Number of failures.

Poisson

LIKNORM_API void liknorm_set_poisson(struct LikNormMachine * machine, double k)

Poisson distribution.

It is a discrete probability distribution that expresses the probability of a given number of events occurring in a fixed interval of time or space if these events occur with a known constant rate and independently of the time since the last event. (Wikipedia.) The probability mass function is given by:

λᵏe^{-λ} / k!,

for which λ is the rate of occurrence and k the number of occurrences.

Parameters
  • machine: Liknorm handler.

  • k: Number of occurrences.