Top | ![]() |
![]() |
![]() |
![]() |
Functions
Object Hierarchy
GObject ╰── NcmFitESMCMCWalker ├── NcmFitESMCMCWalkerAPES ├── NcmFitESMCMCWalkerStretch ╰── NcmFitESMCMCWalkerWalk
Description
Abstract class for implementing walkers for NcmFitESMCMC.
This class provides the tools to construct the walkers used to generate a Monte Carlo Markov Chain using an ensemble sampler. The objects of this class shall be implemented in the NcmFitESMCMC class, which will generate the MCMC sample. Below, there is a small review about an ensemble sampler and the walker features. For more information about ensemble samplers, check [Ensemble Samplers With Affine Invariance, Jonathan Goodman and Jonathan Weare].
A Monte Carlo Markov Chain (MCMC) is an algorithm method to sample from probability distributions without having to sample directly from the distribution. Suppose that we want to generate a sample from an $n$-dimensional distribution $\pi(X)$. If the function is complicated enough, it is not an easy task to compute the inverse and the norm of the distribution to sample from it, and that is when the MCMC method may be used.
The MCMC method consists of a point proposal $Y$ based on a kernel $K(Y|X)$, which depends on a step proposal and in an acceptance probability $A(Y|X)$, such that the accepted points are distributed by the target distribution $\pi(X)$. This process of proposing one point in a time $t$ and acceptance or rejection based on the distribution may be viewed as one walker. The ensemble sampler is defined as \begin{align} \label{eq2.1} \vec{X}&\equiv(X_1,X_2,X_3,...,X_L) ,\end{align} where $X_i \in \mathbb{R}^{n}$ is called a walker and $\vec{X} \in \mathbb{R}^{Ln}$. The process now consists in proposing points for all the walkers in a time $t$ to a new point in $t+1$, using the information from the other walkers. The ensemble considers the position of the remaining walkers when moving each particular walker, which is the advantage of this method when comparing it to single walker algorithms since this feature leads to faster convergences. The desired target joint distribution of the ensemble is one that let the walkers be independent of each other, such that each walker has the desired target distribution $\pi(X)$, that is, \begin{align} \label{eq2.2} \Pi(\vec{X})=\prod_{i}^{L}\pi(X_i) .\end{align}
The user must provide the input the values: nparams
- ncm_fit_esmcmc_walker_set_nparams()
, size
- ncm_fit_esmcmc_walker_set_size()
,
walker
_name
- ncm_fit_esmcmc_walker_new_from_name()
. For more information about the algorithm, see the description below.
- The NcmFitESMCMCWalker class only has virtual methods, Therefore, to initialize this class, one must insert the walker
_name
,
which defines from which child object the class will inherit its methods.
- This class has the tools to implement the following methods: the step of the walker, which defines how the point $Y$ is proposed and how it should be accepted; and the acceptance probability, unnormalized and normalized;
- To use this class, one must use the ncm_fit_esmcmc_walker_new_from_name()
function or initialize an instance from the child objects NcmFitESMCMCWalkerAPES, NcmFitESMCMCWalkerStretch or NcmFitESMCMCWalkerWalk. After the initiation, one shall define which parameters must be changed and then prepare the necessary data to implement this class in the NcmFitESMCMC class.
The NcmFitESMCMCWalker class does not generate an MCMC sample by itself. For an example of implementation, check the documentation in NcmFitESMCMCWalkerAPES.
Functions
ncm_fit_esmcmc_walker_new_from_name ()
NcmFitESMCMCWalker *
ncm_fit_esmcmc_walker_new_from_name (const gchar *walker_name
);
This function returns a new NcmFitESMCMCWalker whose type is defined by walker_name
.
ncm_fit_esmcmc_walker_ref ()
NcmFitESMCMCWalker *
ncm_fit_esmcmc_walker_ref (NcmFitESMCMCWalker *walker
);
Increases the reference count of walker
atomically.
ncm_fit_esmcmc_walker_free ()
void
ncm_fit_esmcmc_walker_free (NcmFitESMCMCWalker *walker
);
Decreases the reference count of walker
atomically.
ncm_fit_esmcmc_walker_clear ()
void
ncm_fit_esmcmc_walker_clear (NcmFitESMCMCWalker **walker
);
Decreases the reference count of *walker
atomically and sets the pointer *walker
to null.
ncm_fit_esmcmc_walker_set_size ()
void ncm_fit_esmcmc_walker_set_size (NcmFitESMCMCWalker *walker
,guint size
);
Sets the walker's size.
[virtual set_size]
ncm_fit_esmcmc_walker_get_size ()
guint
ncm_fit_esmcmc_walker_get_size (NcmFitESMCMCWalker *walker
);
[virtual get_size]
ncm_fit_esmcmc_walker_set_nparams ()
void ncm_fit_esmcmc_walker_set_nparams (NcmFitESMCMCWalker *walker
,guint nparams
);
Sets the number parameters of the walker.
[virtual set_nparams]
ncm_fit_esmcmc_walker_get_nparams ()
guint
ncm_fit_esmcmc_walker_get_nparams (NcmFitESMCMCWalker *walker
);
[virtual get_nparams]
ncm_fit_esmcmc_walker_setup ()
void ncm_fit_esmcmc_walker_setup (NcmFitESMCMCWalker *walker
,NcmMSet *mset
,GPtrArray *theta
,GPtrArray *m2lnL
,guint ki
,guint kf
,NcmRNG *rng
);
Setup the walkers ki
to kf
(kf
not included).
[virtual setup]
ncm_fit_esmcmc_walker_step ()
void ncm_fit_esmcmc_walker_step (NcmFitESMCMCWalker *walker
,GPtrArray *theta
,GPtrArray *m2lnL
,NcmVector *thetastar
,guint k
);
Move the k
-th walker and assign the new position in thetastar
.
[virtual step]
ncm_fit_esmcmc_walker_prob ()
gdouble ncm_fit_esmcmc_walker_prob (NcmFitESMCMCWalker *walker
,GPtrArray *theta
,GPtrArray *m2lnL
,NcmVector *thetastar
,guint k
,const gdouble m2lnL_cur
,const gdouble m2lnL_star
);
Calculates the transition probability
[virtual prob]
ncm_fit_esmcmc_walker_prob_norm ()
gdouble ncm_fit_esmcmc_walker_prob_norm (NcmFitESMCMCWalker *walker
,GPtrArray *theta
,GPtrArray *m2lnL
,NcmVector *thetastar
,guint k
);
Calculates the transition probability norm, this method is used in the MPI implementation.
[virtual prob_norm]
ncm_fit_esmcmc_walker_clean ()
void ncm_fit_esmcmc_walker_clean (NcmFitESMCMCWalker *walker
,guint ki
,guint kf
);
Cleanup after moving walkers from ki
to kf
(kf
not included).
[virtual clean]
ncm_fit_esmcmc_walker_desc ()
const gchar *
ncm_fit_esmcmc_walker_desc (NcmFitESMCMCWalker *walker
);
[virtual desc]
Property Details
The “nparams”
property
“nparams” guint
Number of parameters.
Owner: NcmFitESMCMCWalker
Flags: Read / Write / Construct
Allowed values: >= 1
Default value: 1
The “size”
property
“size” guint
Number of walkers.
Owner: NcmFitESMCMCWalker
Flags: Read / Write / Construct
Allowed values: >= 1
Default value: 100