APEMoST
Defines | Functions

src/mcmc.h File Reference

#include <stdio.h>
#include <stdlib.h>
#include "mcmc_struct.h"
#include "markov_chain.h"
#include "mcmc_gettersetter.h"

Go to the source code of this file.

Defines

#define DUMP_FORMAT   "%.15e"
#define NOASSERT
#define assert(cond)

Functions

mcmcmcmc_load (const char *filename, const char *datafilename)
mcmcmcmc_load_params (const char *filename)
void mcmc_load_data (mcmc *m, const char *datafilename)
void mcmc_reuse_data (mcmc *m, const mcmc *m_orig)
mcmcmcmc_free (mcmc *m)
void mcmc_check (const mcmc *m)
void mcmc_append_current_parameters (mcmc *m)
void mcmc_dump_y_dat (mcmc *m, const gsl_vector *y_dat, const char *filename)
void mcmc_dump_flush (const mcmc *m)
void mcmc_dump_close (mcmc *m)
void mcmc_open_dump_files (mcmc *m, const char *suffix, int index, char *mode)
void mcmc_dump_current (const mcmc *m)
void mcmc_dump_probabilities (const mcmc *m, int n_values, const char *suffix)
void mcmc_check_best (mcmc *m)
void calc_model (mcmc *m, const gsl_vector *old_values)
void calc_model_for (mcmc *m, const unsigned int i, const double old_value)

Define Documentation

#define assert (   cond)
#define DUMP_FORMAT   "%.15e"

Public methods of the class How many digits should be used for writing numbers out?

If you find the precision too low, increase here. If you find the program too slow, decrease here.

Referenced by calc_marginal_distribution(), main(), mcmc_dump_current(), write_calibration_summary(), write_calibrations_file(), and write_params_file().

#define NOASSERT

Turns additional sanity checks off.

One could think that turning this off would improve performance, but tests have shown the modification is not significant.


Function Documentation

void calc_model ( mcmc m,
const gsl_vector *  old_values 
)

update the model according to the new parameter values and recalculate the probability for the model

Parameters:
m
old_valuesprevious values, or NULL

References apply_formula(), assert, mcmc::data, get_beta(), get_n_par(), get_params_for(), get_prior(), Problem::LogLike, p, mcmc::params, Problem::Prior, set_prior(), set_prob(), and SIGMA.

Referenced by calc_model_for(), calibrate_first(), calibrate_rest(), main(), and markov_chain_step().

void calc_model_for ( mcmc m,
const unsigned int  i,
const double  old_value 
)

update the model as the new parameter value i changed and recalculate the probability for the model

Parameters:
m
iindex of the parameter value that changed
old_valueprevious value of the parameter

References calc_model().

Referenced by main(), and markov_chain_step_for().

void mcmc_append_current_parameters ( mcmc m)

adds the current parameter values to params_distr as nth iteration was: add_values

Parameters:
m

References mcmc_dump_current(), and mcmc::n_iter.

Referenced by run_sampler(), test_append(), and test_write_prob().

void mcmc_check ( const mcmc m)
void mcmc_check_best ( mcmc m)

check if a new best value has been found

Parameters:
m

References dump_v, mcmc::params, mcmc::prob, mcmc::prob_best, and set_params_best().

Referenced by assess_acceptance_rate(), burn_in(), markov_chain_calibrate_orig(), and run_sampler().

void mcmc_dump_close ( mcmc m)

close output files

References assert, mcmc::files, get_n_par(), mem_free, and r.

Referenced by mcmc_free().

void mcmc_dump_current ( const mcmc m)

append current parameters to files, unflushed.

References DUMP_FORMAT, mcmc::files, get_n_par(), and mcmc::params.

Referenced by mcmc_append_current_parameters().

void mcmc_dump_flush ( const mcmc m)

flush output files

References mcmc::files, and get_n_par().

Referenced by report(), and test_write_prob().

void mcmc_dump_probabilities ( const mcmc m,
int  n_values,
const char *  suffix 
)

write probability/distribution (params_distr) out to files.

The files are named after the parameter names, with .prob.dump appended. You can use those files to build a histogram of where the algorithm has been (and how often) to find out

Parameters:
m
n_valuesuse the n last iterations. if negative, all are used.
suffixadded to output filename as a suffix
void mcmc_dump_y_dat ( mcmc m,
const gsl_vector *  y_dat,
const char *  filename 
)

References mcmc::data.

Referenced by test_write().

mcmc* mcmc_free ( mcmc m)
mcmc* mcmc_load ( const char *  filename,
const char *  datafilename 
)

create and initialize a mcmc class using the configuration given in

Parameters:
filenamefile containing the model parameters
datafilenamex/y observed data
Returns:
the created mcmc class

References mcmc_load_data(), and mcmc_load_params().

Referenced by test_load(), test_random(), test_write(), and test_write_prob().

void mcmc_load_data ( mcmc m,
const char *  datafilename 
)

loads the data from the given file as x/y values

Parameters:
m
datafilename

References dump_s, IFDEBUGPARSER, and mcmc_check().

Referenced by main(), mcmc_load(), and setup_chains().

mcmc* mcmc_load_params ( const char *  filename)

create and initialize a mcmc class using the configuration given in

Parameters:
filenamefile containing the model parameters
Returns:
the created mcmc class

References assert, countlines(), dump_i, IFDEBUGPARSER, mcmc_init(), openfile(), and r.

Referenced by main(), mcmc_load(), and setup_chains().

void mcmc_open_dump_files ( mcmc m,
const char *  suffix,
int  index,
char *  mode 
)

open dump files The filenames are created by the scheme paramname+suffix+"-"+index+extension

Parameters:
m
suffix
index
mode'w' for writing, 'a' for append, 'r' for reading

References assert, ASSURE_DUMP_ENABLED, dump_s, mcmc::files, get_n_par(), IFVERBOSE, mem_calloc, mem_free, mcmc::n_par, and mcmc::params_descr.

Referenced by prepare_and_run_sampler(), and test_write_prob().

void mcmc_reuse_data ( mcmc m,
const mcmc m_orig 
)

reference to another object for x and y-data.

Parameters:
mthe object to fill
m_origthe object with loaded data

References assert, mcmc::data, debug, IFDEBUGPARSER, and mcmc_check().

Referenced by setup_chains().