Patterns in static

Apophenia

apop_arms.c File Reference

Defines

Functions


Detailed Description

adaptive rejection metropolis sampling


Define Documentation

#define XEPS   0.00001

(C) Wally Gilks; see documentation below for details. Adaptations for Apophenia (c) 2009 by Ben Klemens. Licensed under the modified GNU GPL v2; see COPYING and COPYING2.


Function Documentation

void apop_arms_draw ( double *  out,
gsl_rng *  r,
apop_model m 
)

Adaptive rejection metropolis sampling.

This is a function to make random draws from any univariate distribution (more or less).

The author, Wally Gilks, explains on http://www.amsta.leeds.ac.uk/~wally.gilks/adaptive.rejection/web_page/Welcome.html, that ``ARS works by constructing an envelope function of the log of the target density, which is then used in rejection sampling (see, for example, Ripley, 1987). Whenever a point is rejected by ARS, the envelope is updated to correspond more closely to the true log density, thereby reducing the chance of rejecting subsequent points. Fewer ARS rejection steps implies fewer point-evaluations of the log density.''

  • It accepts only functions with univariate inputs. I.e., it will put a single value in the vector part of a apop_data set, and then evaluate the log likelihood at that point.
  • It is currently the default for the apop_draw function, so you can just call that if you prefer.
  • There are a great number of parameters, in the apop_arms_settings structure. The structure also holds a history of the points tested to date. That means that the system will be more acurate as more draws are made. It also means that if the parameters change, or you use apop_model_copy, you should call Apop_settings_rm_group(your_model, apop_arms) to clear the model of points that are not valid for a different situation.
  • Here are the parameters that you may want to set, via a form like apop_model_add_group(your_model, apop_arms, .model=your_model, .xl=8, .xr =14);. The model element is mandatory; you'll get a run-time complaint if you forget it.

model : the model from which I will draw. Must have either a log_likelihood or p method.
*xinit : a double* giving starting values for x in ascending order. Default: -1, 0, 1. If this isn't NULL, I need at least three items.
ninit : number of elements in xinit
xl : left bound. If you don't give me one, I'll use min[min(xinit)/10, min(xinit)*10].
xr : right bound. If you don't give me one, I'll use max[max(xinit)/10, max(xinit)*10].
convex : adjustment for convexity
npoint : maximum number of envelope points. I malloc space for this many doubles at the outset default = 1e5
do_metro : whether the metropolis step is required (I.e., set to one if you're not sure if the function is log-concave). Set to 'y'es or 'n'o
*xprev : previous value from markov chain
*neval : on exit, the number of function evaluations performed

SourceForge.net Logo

Autogenerated by doxygen on 23 Nov 2009.