Patterns in static

Apophenia

Macros | Functions
apop_arms.c File Reference

Macros

#define XEPS   0.00001 /* critical relative x-value difference */
 
#define YEPS   0.1 /* critical y-value difference */
 
#define EYEPS   0.001 /* critical relative exp(y) difference */
 
#define YCEIL   50. /* maximum y avoiding overflow in exp(y) */
 

Functions

void invert (double prob, arms_state *env, POINT *p)
 
int test (arms_state *state, POINT *p, apop_arms_settings *params, gsl_rng *r)
 
int update (arms_state *state, POINT *p, apop_arms_settings *params)
 
int meet (POINT *q, arms_state *state, apop_arms_settings *params)
 
double area (POINT *q)
 
double expshift (double y, double y0)
 
double logshift (double y, double y0)
 
double perfunc (apop_arms_settings *, double x)
 
void display (FILE *f, arms_state *env, apop_arms_settings *)
 
int initial (apop_arms_settings *params, arms_state *state)
 
 Apop_settings_copy (apop_arms, out->state=malloc(sizeof(arms_state));*out->state=*in->state;) Apop_settings_free(apop_arms
 
 if (in->state)
 
 Apop_settings_init (apop_arms, if((in.xl||in.xr)&&!in.xinit) out->xinit=(double[]){in.xl+GSL_DBL_EPSILON,(in.xl+in.xr)/2., in.xr-GSL_DBL_EPSILON};else{Apop_varad_set(xinit,((double[]){-1, 0, 1}));}Apop_varad_set(ninit, 3);Apop_varad_set(xl, GSL_MIN(out->xinit[0]/10., out->xinit[0]*10)-.1);Apop_varad_set(xr, GSL_MAX(out->xinit[out->ninit-1]/10., out->xinit[out->ninit-1]*10)+.1);Apop_varad_set(convex, 0);Apop_varad_set(npoint, 100);Apop_varad_set(do_metro, 'y');Apop_varad_set(xprev,(out->xinit[0]+out->xinit[out->ninit-1])/2.);Apop_varad_set(neval, 1000);Apop_assert(out->model,"the model input (e.g.: .model = parent_model) is mandatory.");out->state=malloc(sizeof(arms_state));Apop_assert(out->state,"Malloc failed. Out of memory?");*out->state=(arms_state){};int err=initial(out, out->state);Apop_assert_c(!err, NULL, 0,"init failed, error %i. Returning NULL", err);if(out->do_metro=='y'){out->state->metro_xprev=out->xprev;out->state->metro_yprev=perfunc(out, out->xprev);assert(isfinite(out->state->metro_xprev));assert(isfinite(out->state->metro_yprev));}) void distract_doxygen_arms()
 
int apop_arms_draw (double *out, gsl_rng *r, apop_model *m)
 Adaptive rejection metropolis sampling. More...
 

Detailed Description

adaptive rejection metropolis sampling

Macro Definition Documentation

#define XEPS   0.00001 /* critical relative x-value difference */

(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

int 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 accurate 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.
  • See apop_arms_settings for the list of 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.

Autogenerated by doxygen on Sun Oct 26 2014 (Debian 0.999b+ds3-2).