/* Mixture model from a Dirichlet process (DP), see http://www.robots.ox.ac.uk/~fwood/anglican/examples/viewer/?worksheet=nonparametrics/dp-mixture-model https://en.wikipedia.org/wiki/Dirichlet_process Samples are drawn from a mixture of normal distributions whose parameters are defined by means of a Dirichlet process, so the number of components is not fixed in advance. For each component, the variance is sampled from a gamma distribution and the mean is sampled from a Gaussian with mean 0 and variance 30 times the variance of the component. Given some observations, the aim is to find how the distribution of values is updated. Less observations are considered with respect to http://www.robots.ox.ac.uk/~fwood/anglican/examples/viewer/?worksheet=nonparametrics/dp-mixture-model because the weights go rapidly to 0. */ /** ?- dens(1000). % draw the prior and posterior densities ?- prior(1000). % draw the prior density ?- post(1000). % draw the posterior density ?- post_exp(1000). % draw the posterior density using the exponential function. */ :- use_module(library(mcintyre)). :- use_module(library(cplint_r)). :- mc. :- begin_lpad. dp_n_values(N,N,_Alpha,[]):-!. dp_n_values(N0,N,Alpha,[[V]-1|Vs]):- N0