Patterns in static


apop_mcmc_proposal_s Struct Reference

Data Fields

int accept_count
int(* adapt_fn )(struct apop_mcmc_proposal_s *ps, struct apop_mcmc_settings *ms)
int reject_count
void(* step_fn )(double const *, struct apop_mcmc_proposal_s *, struct apop_mcmc_settings *)

Detailed Description

A proposal distribution for apop_mcmc_settings and its accompanying functions and information. By default, these will be apop_multivariate_normal models. The step_fn and adapt_fn have to be written around the model and your preferences. For the defaults, the step function recenters the mean of the distribution around the last accepted proposal, and the adapt function widens $\Sigma$ for the Normal if the accept rate is too low; narrows it if the accept rate is too large.

You may provide an array of proposals. The length of the list of proposals must match the number of chunks, as per the gibbs_chunks setting in the apop_mcmc_settings group that the array of proposals is a part of. Each proposal must be initialized to include all elements, and the step and adapt functions probably have to be written anew for each type of model.

Field Documentation

int(* apop_mcmc_proposal_s::adapt_fn)(struct apop_mcmc_proposal_s *ps, struct apop_mcmc_settings *ms)

Called every step, to adapt the proposal distribution using information to this point in the chain.

apop_model * apop_mcmc_proposal_s::proposal

The distribution from which test parameters will be drawn. After getting the draw using the draw method of the proposal, the base model's parameters element is filled using apop_data_fill. If NULL, apop_model_metropolis will use a Multivariate Normal with the appropriate dimension, mean zero, and covariance matrix I. If not NULL, be sure to parameterize your model with an initial position.

int apop_mcmc_proposal_s::reject_count

If there are multiple apop_mcmc_proposal_s structs for multiple chunks, These count accepts/rejects for this chunk. The apop_mcmc_settings group has a total for the aggregate across all chunks.

void(* apop_mcmc_proposal_s::step_fn)(double const *, struct apop_mcmc_proposal_s *, struct apop_mcmc_settings *)

Modifies the parameters of the proposal distribution given a successful draw. Typically, this function writes the drawn data point to the parameter set. If the draw is a scalar, the default function sets the 0th element of the model's parameter set with the draw (works for the apop_normal and other models). If the draw has multiple dimensions, they are all copied to the parameter set, which must have the same size.