Patterns in static

Apophenia

apop_update.c File Reference

Functions


Detailed Description

The apop_update function. The header is in asst.h.


Function Documentation

apop_model* apop_update ( apop_data data,
apop_model prior,
apop_model likelihood,
gsl_rng *  rng 
)

Take in a prior and likelihood distribution, and output a posterior distribution.

This function first checks a table of conjugate distributions for the pair you sent in. If the names match the table, then the function returns a closed-form model with updated parameters. If the parameters aren't in the table of conjugate priors/likelihoods, then it uses Markov Chain Monte Carlo to sample from the posterior distribution, and then outputs a histogram model for further analysis. Notably, the histogram can be used as the input to this function, so you can chain Bayesian updating procedures.

To change the default settings (MCMC starting point, periods, burnin...), add an apop_update_settings struct to the prior.

Here are the conjugate distributions currently defined:

Prior

Likelihood

Notes

Beta

Binomial

Beta

Bernoulli

Exponential

Gamma

Gamma likelihood represents the distribution of $\lambda^{-1}$, not plain $\lambda$

Normal

Normal

Assumes prior with fixed $\sigma$; updates distribution for $\mu$

Gamma

Poisson

Uses sum and size of the data

Parameters:
data The input data, that will be used by the likelihood function (default = NULL.)
prior The prior apop_model (No default, must not be NULL.)
likelihood The likelihood apop_model. If the system needs to estimate the posterior via MCMC, this needs to have a draw method. (No default, must not be NULL.)
rng A gsl_rng, already initialized (e.g., via apop_rng_alloc). (default: see Auto-allocated RNGs)
Returns:
an apop_model struct representing the posterior, with updated parameters.
Todo:
The table of conjugate prior/posteriors (in its static check_conjugacy subfuction), is a little short, and can always be longer.
apop_update_settings* apop_update_settings_alloc ( apop_data d  ) 

Allocate an apop_update_settings struct. See also apop_update_settings_init, which is not deprecated.

apop_update_settings* apop_update_settings_init ( apop_update_settings  in  ) 

Allocate an apop_update_settings struct.

SourceForge.net Logo

Autogenerated by doxygen on 23 Nov 2009.