![]() |
|
The apop_update function. The header is in asst.h.
| 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 |
Gamma likelihood represents the distribution of | ||
Assumes prior with fixed | ||
Uses sum and size of the data |
| 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) |
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.