Download User Manual for

Transcript
18
CHAPTER 2. THE MONTECUBES C LIBRARY
Note that the user does not need to use all of these arguments in the
function. For example, if the user wants to construct a simulation using
transition functions which do not depend on the current step, argument 1
will not be used. However, the definition of the function should have this
structure.
proposal – The function to use in order to generate new test steps.
udata – User defined data to be passed along to proposal.
Returns:
MCB OK as it will always be possible to set the function and user
data pointers. It is up to the user to ensure that the function works
properly.
int mcb setTransitionRatioFunction (double (*ratio)(const glb params,
const glb params, const glb params, const int*, const int*, int,
int, double, void*), void* udata)
If mcb setStepProposalFunction is used to set the proposal function to
an asymmetric function (i.e., W(x̂ → xn ) 6= W(xn → x̂)), then this
will affect the acceptance criteria that should be used in the Metropolis–
Hastings algorithm. This method is used to implement this change of
acceptance criteria and sets the function that is used to compute the ratio
W(x̂ → xn )/W(xn → x̂). If this method is not called, or ratio is NULL,
then it will be assumed that the ratio is 1. The function ratio should take
nine (9) arguments according to the following specification (see App. A.1
for the Monte Carlo theory notation):
1. const glb params: The current step xn in the simulation.
2. const glb params: The proposed new step x̂ in the simulation.
3. const glb params: The step sizes used in the simulation.
4. const int*: An integer array with flags notifying if a parameter
should be free in the simulation or not (1 for free, 0 for fixed).
5. const int*: An integer array with flags notifying if a density should
be free in the simulation or not (1 for free, 0 for fixed).
6. int: The number of free parameters Nf in the simulation (i.e., the
number of ones in argument 4).
7. int: The number of free densities Nd in the simulation (i.e., the
number of ones in argument 5).
8. double: A parameter denoting the relative step size. This will be
one in the simulation, but the starting samples in the simulation will
be determined from taking a step with a larger step size.