Mathematical Relations#

AeMCMC encodes mathematical relations using kanren goals.

aemcmc.conjugates.gamma_poisson_conjugateo(srng, observed_rv_expr, posterior_expr)[source]#

Relation for the conjugate posterior of a gamma prior with a Poisson observation model.

\[\frac{ Y \sim \operatorname{Poisson}\left(\lambda\right), \quad \lambda \sim \operatorname{Gamma}\left(\alpha, \beta\right) }{ \left(\lambda|Y=y\right) \sim \operatorname{Gamma}\left(\alpha+y, \beta+1\right) }\]
Parameters:
  • srng – The RandomStream used to generate the posterior variates.

  • observed_rv_expr – An expression that represents the observed variable.

  • posterior_exp – An expression that represents the posterior distribution of the latent variable.

aemcmc.conjugates.beta_binomial_conjugateo(srng, observed_rv_expr, posterior_expr)[source]#

Relation for the conjugate posterior of a beta prior with a binomial observation model.

\[\frac{ Y \sim \operatorname{Binom}\left(N, p\right), \quad p \sim \operatorname{Beta}\left(\alpha, \beta\right) }{ \left(p|Y=y\right) \sim \operatorname{Beta}\left(\alpha+y, \beta+N-y\right) }\]
Parameters:
  • srng – The RandomStream used to generate the posterior variates.

  • observed_rv_expr – An expression that represents the observed variable.

  • posterior_exp – An expression that represents the posterior distribution of the latent variable.

aemcmc.transforms.location_scale_transform(in_expr, out_expr)[source]#

Produce a goal that represents the action of lifting and sinking the scale and location parameters of distributions in the location-scale family.

For instance

\[\begin{equation*} \frac{ Y \sim \operatorname{P}(0, 1), \quad X = \mu + \sigma\,Y }{ X \sim \operatorname{P}\left(\mu, \sigma\right) } \end{equation*}\]

where P is any distribution in the location-scale family.

Parameters:
  • in_expr – An expression that represents a random variable whose distribution belongs to the location-scale family.

  • out_expr – An expression for the non-centered representation of this random variable.

aemcmc.transforms.invgamma_exponential(invgamma_expr, invexponential_expr)[source]#

Produce a goal that represents the relation between the inverse gamma distribution and the inverse of an exponential distribution.

\[\begin{equation*} \frac{ X \sim \operatorname{Gamma^{-1}}\left(1, c\right),\quad Y = 1 / X }{ Y \sim \operatorname{Exp}\left(c\right) } \end{equation*}\]
Parameters:
  • invgamma_expr – An expression that represents a random variable with an inverse gamma distribution with a shape parameter equal to 1.

  • invexponential_expr – An expression that represents the inverse of a random variable with an exponential distribution.