NcmFitESMCMC

NcmFitESMCMC — Ensemble sampler Markov Chain Monte Carlo analysis.

Functions

Properties

gboolean auto-trim Read / Write / Construct
guint auto-trim-div Read / Write / Construct
char * data-file Read / Write
NcmFit * fit Read / Write / Construct Only
NcmObjArray * function-array Read / Write / Construct Only
guint intermediary-log Read / Write / Construct
double log-time-interval Read / Write / Construct
double lre-step Read / Write / Construct
double max-runs-time Read / Write / Construct
guint min-runs Read / Write / Construct
NcmFitRunMsgs mtype Read / Write
guint nthreads Read / Write
guint nwalkers Read / Write / Construct Only
NcmMSetTransKern * sampler Read / Write / Construct
NcmMSetCatalogTrimType trim-type Read / Write / Construct
gboolean use-mpi Read / Write / Construct
NcmFitESMCMCWalker * walker Read / Write / Construct Only

Types and Values

Object Hierarchy

    GObject
    ╰── NcmFitESMCMC

Description

NcmFitESMCMC is a class that implements the Ensemble sampler Markov Chain Monte Carlo analysis. The object requires a NcmFit object to be set before running the analysis. The initial points are sampled from a NcmMSetTransKern object. The walkers are defined by a NcmFitESMCMCWalker object.

The NcmFitESMCMC object can be run in parallel using MPI.

Functions

ncm_fit_esmcmc_new ()

NcmFitESMCMC *
ncm_fit_esmcmc_new (NcmFit *fit,
                    guint nwalkers,
                    NcmMSetTransKern *sampler,
                    NcmFitESMCMCWalker *walker,
                    NcmFitRunMsgs mtype);

Creates a new NcmFitESMCMC object using the given parameters.

Parameters

fit

a NcmFit

 

nwalkers

number of walkers

 

sampler

inital points sampler NcmMSetTransKern

 

walker

a NcmFitESMCMCWalker.

[allow-none]

mtype

a NcmFitRunMsgs

 

Returns

the newly created NcmFitESMCMC object.

[transfer full]


ncm_fit_esmcmc_new_funcs_array ()

NcmFitESMCMC *
ncm_fit_esmcmc_new_funcs_array (NcmFit *fit,
                                guint nwalkers,
                                NcmMSetTransKern *sampler,
                                NcmFitESMCMCWalker *walker,
                                NcmFitRunMsgs mtype,
                                NcmObjArray *funcs_array);

Creates a new NcmFitESMCMC object using the given parameters. The funcs_array is used to compute extra columns in the catalog. The functions must be scalar and constant.

Parameters

fit

a NcmFit

 

nwalkers

number of walkers

 

sampler

inital points sampler NcmMSetTransKern

 

walker

a NcmFitESMCMCWalker.

[allow-none]

mtype

a NcmFitRunMsgs

 

funcs_array

a NcmObjArray of scalar functions to include in the catalog.

 

Returns

the newly created NcmFitESMCMC object.

[transfer full]


ncm_fit_esmcmc_ref ()

NcmFitESMCMC *
ncm_fit_esmcmc_ref (NcmFitESMCMC *esmcmc);

Increases the reference count of esmcmc by one.

Parameters

esmcmc

a NcmFitESMCMC

 

Returns

the same esmcmc object.

[transfer full]


ncm_fit_esmcmc_free ()

void
ncm_fit_esmcmc_free (NcmFitESMCMC *esmcmc);

Decreases the reference count of esmcmc by one. If the reference count reaches zero, all memory allocated by the object is released.

Parameters

esmcmc

a NcmFitESMCMC

 

ncm_fit_esmcmc_clear ()

void
ncm_fit_esmcmc_clear (NcmFitESMCMC **esmcmc);

Decreases the reference count of esmcmc by one. If the reference count reaches zero, all memory allocated by the object is released. The esmcmc pointer is set to NULL.

Parameters

esmcmc

a NcmFitESMCMC

 

ncm_fit_esmcmc_set_data_file ()

void
ncm_fit_esmcmc_set_data_file (NcmFitESMCMC *esmcmc,
                              const gchar *filename);

Sets the data file to use for the chains catalog.

Parameters

esmcmc

a NcmFitESMCMC

 

filename

a filename.

 

ncm_fit_esmcmc_set_sampler ()

void
ncm_fit_esmcmc_set_sampler (NcmFitESMCMC *esmcmc,
                            NcmMSetTransKern *sampler);

ncm_fit_esmcmc_set_mtype ()

void
ncm_fit_esmcmc_set_mtype (NcmFitESMCMC *esmcmc,
                          NcmFitRunMsgs mtype);

Sets the type of messages to use when running.

Parameters

esmcmc

a NcmFitESMCMC

 

mtype

a NcmFitRunMsgs

 

ncm_fit_esmcmc_set_nthreads ()

void
ncm_fit_esmcmc_set_nthreads (NcmFitESMCMC *esmcmc,
                             guint nthreads);

If nthreads is larger than nwalkers / 2, it will be set to nwalkers / 2.

Parameters

esmcmc

a NcmFitESMCMC

 

nthreads

numbers of simultaneous walkers updates

 

ncm_fit_esmcmc_use_mpi ()

void
ncm_fit_esmcmc_use_mpi (NcmFitESMCMC *esmcmc,
                        gboolean use_mpi);

If use_mpi is TRUE then the parallelization will be accomplished using MPI if any slaves are available. If no slaves are available then it falls back to threads.

Note that parallelization will only occur if the number of threads set using ncm_fit_esmcmc_set_nthreads() is larger than one.

Parameters

esmcmc

a NcmFitESMCMC

 

use_mpi

whether to prefer MPI

 

ncm_fit_esmcmc_set_rng ()

void
ncm_fit_esmcmc_set_rng (NcmFitESMCMC *esmcmc,
                        NcmRNG *rng);

Sets the random number generator to use.

Parameters

esmcmc

a NcmFitESMCMC

 

rng

a NcmRNG

 

ncm_fit_esmcmc_set_auto_trim ()

void
ncm_fit_esmcmc_set_auto_trim (NcmFitESMCMC *esmcmc,
                              gboolean enable);

If enable is TRUE turns on the auto-trimming when performing a run_lre.

Parameters

esmcmc

a NcmFitESMCMC

 

enable

a boolean

 

ncm_fit_esmcmc_set_auto_trim_div ()

void
ncm_fit_esmcmc_set_auto_trim_div (NcmFitESMCMC *esmcmc,
                                  guint div);

Sets the divisor for the auto trim tests.

Parameters

esmcmc

a NcmFitESMCMC

 

div

a unsigned integer

 

ncm_fit_esmcmc_set_auto_trim_type ()

void
ncm_fit_esmcmc_set_auto_trim_type (NcmFitESMCMC *esmcmc,
                                   NcmMSetCatalogTrimType ttype);

Sets the trim type.

Parameters

esmcmc

a NcmFitESMCMC

 

ttype

a NcmMSetCatalogTrimType

 

ncm_fit_esmcmc_set_min_runs ()

void
ncm_fit_esmcmc_set_min_runs (NcmFitESMCMC *esmcmc,
                             guint min_runs);

Sets the minimum number of runs between tests.

Parameters

esmcmc

a NcmFitESMCMC

 

min_runs

a unsigned integer

 

ncm_fit_esmcmc_set_max_runs_time ()

void
ncm_fit_esmcmc_set_max_runs_time (NcmFitESMCMC *esmcmc,
                                  gdouble max_runs_time);

Sets the maximum time for the runs between tests.

Parameters

esmcmc

a NcmFitESMCMC

 

max_runs_time

a unsigned integer

 

ncm_fit_esmcmc_has_rng ()

gboolean
ncm_fit_esmcmc_has_rng (NcmFitESMCMC *esmcmc);

Parameters

esmcmc

a NcmFitESMCMC

 

Returns

whether there is a NcmRNG set.


ncm_fit_esmcmc_get_accept_ratio ()

gdouble
ncm_fit_esmcmc_get_accept_ratio (NcmFitESMCMC *esmcmc);

The acceptance ratio is the ratio of accepted proposals over the total number of proposals.

Parameters

esmcmc

a NcmFitESMCMC

 

Returns

the acceptance ratio.


ncm_fit_esmcmc_get_offboard_ratio ()

gdouble
ncm_fit_esmcmc_get_offboard_ratio (NcmFitESMCMC *esmcmc);

The offboard ratio is the ratio of offboard proposals over the total number of proposals.

Parameters

esmcmc

a NcmFitESMCMC

 

Returns

the offboard ratio.


ncm_fit_esmcmc_get_accept_ratio_last_update ()

gdouble
ncm_fit_esmcmc_get_accept_ratio_last_update
                               (NcmFitESMCMC *esmcmc);

The acceptance ratio is the ratio of accepted proposals over the total number of proposals during the last update.

Parameters

esmcmc

a NcmFitESMCMC

 

Returns

the acceptance ratio.


ncm_fit_esmcmc_get_offboard_ratio_last_update ()

gdouble
ncm_fit_esmcmc_get_offboard_ratio_last_update
                               (NcmFitESMCMC *esmcmc);

The offboard ratio is the ratio of offboard proposals over the total number of proposals during the last update.

Parameters

esmcmc

a NcmFitESMCMC

 

Returns

the offboard ratio.


ncm_fit_esmcmc_start_run ()

void
ncm_fit_esmcmc_start_run (NcmFitESMCMC *esmcmc);

Starts the run. This method should be called before any other run related method.

Parameters

esmcmc

a NcmFitESMCMC

 

ncm_fit_esmcmc_end_run ()

void
ncm_fit_esmcmc_end_run (NcmFitESMCMC *esmcmc);

Terminates the run. This method should be called after all run related methods.

Parameters

esmcmc

a NcmFitESMCMC

 

ncm_fit_esmcmc_reset ()

void
ncm_fit_esmcmc_reset (NcmFitESMCMC *esmcmc);

Resets the run.

Parameters

esmcmc

a NcmFitESMCMC

 

ncm_fit_esmcmc_run ()

void
ncm_fit_esmcmc_run (NcmFitESMCMC *esmcmc,
                    guint n);

Runs the Monte Carlo until it reaches the n -th realization. Note that if the first_id is non-zero it will run n - first_id realizations.

Parameters

esmcmc

a NcmFitESMCMC

 

n

total number of realizations to run

 

ncm_fit_esmcmc_run_lre ()

void
ncm_fit_esmcmc_run_lre (NcmFitESMCMC *esmcmc,
                        guint prerun,
                        gdouble lre);

Runs the ESMCMC algorithm until the least relative error is less than lre . It runs at least prerun pre-runs before starting the algorithm.

Parameters

esmcmc

a NcmFitESMCMC

 

prerun

number of pre-runs

 

lre

least relative error

 

ncm_fit_esmcmc_run_burnin ()

void
ncm_fit_esmcmc_run_burnin (NcmFitESMCMC *esmcmc,
                           guint prerun,
                           guint ntimes);

Runs the ESMCMC algorithm until the prerun -th iterations are reached. Then it runs ntimes times the estimated constant break.

The constant break is the number of iterations after which the variance of the m2lnL is constant.

Parameters

esmcmc

a NcmFitESMCMC

 

prerun

number of pre-runs

 

ntimes

multiplication factor

 

ncm_fit_esmcmc_mean_covar ()

void
ncm_fit_esmcmc_mean_covar (NcmFitESMCMC *esmcmc);

Calculates the mean and covariance of the generated catalog.

Parameters

esmcmc

a NcmFitESMCMC

 

ncm_fit_esmcmc_peek_ser ()

NcmSerialize *
ncm_fit_esmcmc_peek_ser (NcmFitESMCMC *esmcmc);

Peeks the internal NcmSerialize object from esmcmc .

Parameters

esmcmc

a NcmFitESMCMC

 

Returns

the internal NcmSerialize object.

[transfer none]


ncm_fit_esmcmc_get_catalog ()

NcmMSetCatalog *
ncm_fit_esmcmc_get_catalog (NcmFitESMCMC *esmcmc);

Gets the generated catalog of esmcmc .

Parameters

esmcmc

a NcmFitESMCMC

 

Returns

the generated catalog.

[transfer full]


ncm_fit_esmcmc_peek_catalog ()

NcmMSetCatalog *
ncm_fit_esmcmc_peek_catalog (NcmFitESMCMC *esmcmc);

Gets the generated catalog of esmcmc .

Parameters

esmcmc

a NcmFitESMCMC

 

Returns

the generated catalog.

[transfer none]


ncm_fit_esmcmc_peek_fit ()

NcmFit *
ncm_fit_esmcmc_peek_fit (NcmFitESMCMC *esmcmc);

Gets the NcmFit object used by the sampler.

Parameters

esmcmc

a NcmFitESMCMC

 

Returns

the NcmFit object.

[transfer none]


ncm_fit_esmcmc_validate ()

gboolean
ncm_fit_esmcmc_validate (NcmFitESMCMC *esmcmc,
                         gulong pi,
                         gulong pf);

Recalculates the value of $-2\ln(L)$ and compares with the values found in the catalog. This function is particularly useful to check if any problem occured during a multithread evaluation of the likelihood.

Choosing pf == 0 performs the validation from pi to the end.

Parameters

esmcmc

a NcmFitESMCMC

 

pi

initial position

 

pf

final position

 

Returns

Whether the validation was TRUE or FALSE.


ncm_fit_esmcmc_peek_walker ()

NcmFitESMCMCWalker *
ncm_fit_esmcmc_peek_walker (NcmFitESMCMC *esmcmc);

Parameters

esmcmc

a NcmFitESMCMC

 

Returns

the currently used walker NcmFitESMCMCWalker.

[transfer none]

Types and Values

NCM_TYPE_FIT_ESMCMC

#define NCM_TYPE_FIT_ESMCMC (ncm_fit_esmcmc_get_type ())

NCM_FIT_ESMCMC_MIN_SYNC_INTERVAL

#define NCM_FIT_ESMCMC_MIN_SYNC_INTERVAL (10.0)

NCM_FIT_ESMCMC_M2LNL_ID

#define NCM_FIT_ESMCMC_M2LNL_ID (0)

NCM_FIT_ESMCMC_MPI_IN_LEN

#define NCM_FIT_ESMCMC_MPI_IN_LEN (3)

NCM_FIT_ESMCMC_MPI_OUT_LEN

#define NCM_FIT_ESMCMC_MPI_OUT_LEN (1)

NcmFitESMCMC

typedef struct _NcmFitESMCMC NcmFitESMCMC;

Property Details

The “auto-trim” property

  “auto-trim”                gboolean

Whether to automatically trim the catalog.

Owner: NcmFitESMCMC

Flags: Read / Write / Construct

Default value: FALSE


The “auto-trim-div” property

  “auto-trim-div”            guint

Automatically trim divisor.

Owner: NcmFitESMCMC

Flags: Read / Write / Construct

Allowed values: >= 1

Default value: 100


The “data-file” property

  “data-file”                char *

Data filename.

Owner: NcmFitESMCMC

Flags: Read / Write

Default value: NULL


The “fit” property

  “fit”                      NcmFit *

Fit object.

Owner: NcmFitESMCMC

Flags: Read / Write / Construct Only


The “function-array” property

  “function-array”           NcmObjArray *

Functions array.

Owner: NcmFitESMCMC

Flags: Read / Write / Construct Only


The “intermediary-log” property

  “intermediary-log”         guint

Number of intermediary logs.

Owner: NcmFitESMCMC

Flags: Read / Write / Construct

Allowed values: >= 1

Default value: 5


The “log-time-interval” property

  “log-time-interval”        double

Time interval between log.

Owner: NcmFitESMCMC

Flags: Read / Write / Construct

Allowed values: >= 1

Default value: 60


The “lre-step” property

  “lre-step”                 double

Step size in the lre run.

Owner: NcmFitESMCMC

Flags: Read / Write / Construct

Allowed values: [0.01,1]

Default value: 0.1


The “max-runs-time” property

  “max-runs-time”            double

Maximum time between runs.

Owner: NcmFitESMCMC

Flags: Read / Write / Construct

Allowed values: >= 1

Default value: 7200


The “min-runs” property

  “min-runs”                 guint

Minumum number of runs.

Owner: NcmFitESMCMC

Flags: Read / Write / Construct

Allowed values: >= 1

Default value: 10


The “mtype” property

  “mtype”                    NcmFitRunMsgs

Run messages type.

Owner: NcmFitESMCMC

Flags: Read / Write

Default value: NCM_FIT_RUN_MSGS_SIMPLE


The “nthreads” property

  “nthreads”                 guint

Number of threads to run.

Owner: NcmFitESMCMC

Flags: Read / Write

Default value: 0


The “nwalkers” property

  “nwalkers”                 guint

Number of walkers.

Owner: NcmFitESMCMC

Flags: Read / Write / Construct Only

Allowed values: >= 1

Default value: 1


The “sampler” property

  “sampler”                  NcmMSetTransKern *

Initial points sampler.

Owner: NcmFitESMCMC

Flags: Read / Write / Construct


The “trim-type” property

  “trim-type”                NcmMSetCatalogTrimType

Trimming tests to apply.

Owner: NcmFitESMCMC

Flags: Read / Write / Construct

Default value: NCM_MSET_CATALOG_TRIM_TYPE_ESS


The “use-mpi” property

  “use-mpi”                  gboolean

Use MPI instead of threads.

Owner: NcmFitESMCMC

Flags: Read / Write / Construct

Default value: TRUE


The “walker” property

  “walker”                   NcmFitESMCMCWalker *

Walker object.

Owner: NcmFitESMCMC

Flags: Read / Write / Construct Only