greta-dev / greta

simple and scalable statistical modelling in R
https://greta-stats.org
Other
527 stars 63 forks source link

joint distribution constructor #227

Closed goldingn closed 6 years ago

goldingn commented 6 years ago

Some models (such as a multivariate hidden Markov model) manipulate joint distributions composed of univariate (or possibly also multivariate) distributions.

Ie. a vector-valued random variable X with dimension k is assumed to follow some distribution pi(X), constructed of component univariate distributions: pi(X) = pi[1] (X[1]) pi[2] (X[2]) ... pi[k] (X[k])*

These distributions are conditionally independent, so in most models they can just be defined separately on each element of X, with no need for an extra function. Though in models like the HMM and some mixture models, it would be convenient to create a new joint distribution from others, which could then be manipulated. The syntax might look like:

X <- joint(normal(0, 1),
           uniform(0,1))

for a variable following a joint distribution of dimension 2. Like other multivariate distributions, each row would be treated as an independent realisation so other dimensions would have to conform.

The internals would be similar to those for mixture() though the density would just require a rowwise summation of log probabilities.

goldingn commented 6 years ago

Implemented on the dev branch now.