APEMoST
Defines | Functions

src/markov_chain.h File Reference

#include "mcmc.h"
#include "define_defaults.h"

Go to the source code of this file.

Defines

#define DEFAULT_ADJUST_STEP   0.5
#define NO_RESCALING_LIMIT   15
#define ITER_READJUST   200
#define CIRCULAR_PARAMS   0
#define ACCURACY_DEVIATION_FACTOR   0.25

Functions

void markov_chain_calibrate (mcmc *m, const unsigned int burn_in_iterations, double desired_acceptance_rate, const double max_ar_deviation, const unsigned int iter_limit, double mul, const double adjust_step)
void markov_chain_step (mcmc *m)
void markov_chain_step_for (mcmc *m, const unsigned int index)
void rmw_adapt_stepwidth (mcmc *m, double prob_old)
void burn_in (mcmc *m, const unsigned int burn_in_iterations)
unsigned int assess_acceptance_rate (mcmc *m, unsigned int param, double desired_acceptance_rate, double min_accuracy, double max_accuracy, double *acceptance_rate, double *accuracy)
void restart_from_best (mcmc *m)

Define Documentation

#define ACCURACY_DEVIATION_FACTOR   0.25

How good should the acceptance rate be calculated in dependence of deviation from the desired value? accuracy = factor * deviation

Referenced by assess_acceptance_rate().

#define CIRCULAR_PARAMS   0

Which parameters are circular?

e.g. if the first and second parameters are angles, you write CIRCULAR_PARAMS=1,2; Do not use zero for the first parameter.

N.B.: if you have a angle, you will want to make it go from 0 to 1 or similar and use pi in your formula. This way it will be more exact.

Referenced by do_step_for().

#define DEFAULT_ADJUST_STEP   0.5

Referenced by calibrate_first(), and calibrate_rest().

#define ITER_READJUST   200
#define NO_RESCALING_LIMIT   15

Function Documentation

unsigned int assess_acceptance_rate ( mcmc m,
unsigned int  param,
double  desired_acceptance_rate,
double  min_accuracy,
double  max_accuracy,
double *  acceptance_rate,
double *  accuracy 
)

Get acceptance rate. The closer the acceptance rate is to the desired acceptance rate, the more accurately will it be assessed.

Parameters:
min_accuracyyou can request a upper limit on the accuracy, e.g. 1%. any calculation will have at most the accuracy of 1% then. Otherwise put 0 here.
max_accuracyyou can request a lower limit on the accuracy, e.g. 0.1% any calculation will have at least the accuracy of 0.1% then. Otherwise put 1 here.
acceptance_ratehere the a/r gets stored
accuracyhere the accuracy gets stored
Returns:
iterations used

Get acceptance rate. The closer the acceptance rate is to the desired acceptance rate, the more accurately will it be assessed.

Parameters:
m
param
desired_acceptance_rate
min_accuracyyou can request a upper limit on the accuracy, e.g. 1%. any calculation will have at most the accuracy of 1% then. Otherwise put 0 here.
max_accuracyyou can request a lower limit on the accuracy, e.g. 0.1% any calculation will have at least the accuracy of 0.1% then. Otherwise put 1 here.
acceptance_ratehere the a/r gets stored
accuracyhere the accuracy gets stored
Returns:
iterations used

References abs_double, ACCURACY_DEVIATION_FACTOR, assert, clear_bit(), get_bit(), get_n_par(), get_params_accepts_for(), get_params_accepts_global(), IFVERBOSE, markov_chain_step(), markov_chain_step_for(), mcmc_check_best(), reset_accept_rejects(), and set_bit().

Referenced by markov_chain_calibrate_alt(), markov_chain_calibrate_linear_regression(), markov_chain_calibrate_multilinear_regression(), and markov_chain_calibrate_quadratic().

void burn_in ( mcmc m,
const unsigned int  burn_in_iterations 
)
void markov_chain_calibrate ( mcmc m,
const unsigned int  burn_in_iterations,
double  desired_acceptance_rate,
const double  max_ar_deviation,
const unsigned int  iter_limit,
double  mul,
const double  adjust_step 
)

create/calibrate the markov-chain

Parameters:
m
desired_acceptance_rateaverage acceptance rates for individual parameters to be achieved
max_ar_deviationallowed deviation from desired_acceptance_rate
burn_in_iterationsnumber of burn-in iterations
iter_limitnumber of iterations for step width calibration
mulfactor for adjusting the step width during calibration
adjust_stepgives the factor with which to adjust the stepwidths after burn-in

References burn_in(), dump_d, markov_chain_calibrate_alt(), markov_chain_calibrate_multilinear_regression(), markov_chain_calibrate_orig(), and markov_chain_calibrate_quadratic().

Referenced by calibrate_first(), and calibrate_rest().

void markov_chain_step ( mcmc m)
void markov_chain_step_for ( mcmc m,
const unsigned int  index 
)

take a step using the markov-chain for the indexth parameter

Parameters:
m
indexthe param to look at

References calc_model_for(), do_step_for(), get_prob(), inc_params_accepts_for(), inc_params_rejects_for(), mcmc_check(), mcmc::params, and set_params_for().

Referenced by assess_acceptance_rate(), and markov_chain_calibrate_orig().

void restart_from_best ( mcmc m)

Set the best parameters value found so far as current value, as well as the probability.

References dup_vector(), get_params_best(), get_prob_best(), set_params(), and set_prob().

Referenced by burn_in(), and markov_chain_calibrate_orig().

void rmw_adapt_stepwidth ( mcmc m,
double  prob_old 
)