NcmFitMC

NcmFitMC — Monte Carlo analysis.

Functions

Properties

NcmMSet * fiducial Read / Write / Construct
NcmFit * fit Read / Write / Construct Only
gboolean keep-order Read / Write / Construct
NcmFitRunMsgs mtype Read / Write
guint nthreads Read / Write
NcmFitMCResampleType rtype Read / Write / Construct

Types and Values

Object Hierarchy

    GEnum
    ╰── NcmFitMCResampleType
    GObject
    ╰── NcmFitMC

Description

This object implements a Monte Carlo analysis. This object is initialized with a NcmFit object and a NcmMSet object. The NcmFit object is used to calculate the likelihood of the NcmMSet object. The NcmMSet object is used to sample the parameter space.

The NcmFitMC object will resample the likelihood using the input NcmMSet object as a fiducial model. The resampling can be done in three ways: NCM_FIT_MC_RESAMPLE_FROM_MODEL, NCM_FIT_MC_RESAMPLE_BOOTSTRAP_NOMIX and NCM_FIT_MC_RESAMPLE_BOOTSTRAP_MIX. The first option will resample the likelihood from the input NcmMSet object. The other two options will resample the likelihood from the original likelihood data using bootstrap resampling. The difference between the last two options is that the NCM_FIT_MC_RESAMPLE_BOOTSTRAP_NOMIX will resample each NcmData separately while the NCM_FIT_MC_RESAMPLE_BOOTSTRAP_MIX will resample all NcmData together.

Functions

NcmFitMCResample ()

void
(*NcmFitMCResample) (NcmDataset *dset,
                     NcmMSet *mset,
                     NcmRNG *rng);

ncm_fit_mc_new ()

NcmFitMC *
ncm_fit_mc_new (NcmFit *fit,
                NcmFitMCResampleType rtype,
                NcmFitRunMsgs mtype);

Creates a new NcmFitMC object with the fit object fit , the resample type rtype and the run messages type mtype .

Parameters

fit

a NcmFit

 

rtype

a NcmFitMCResampleType

 

mtype

a NcmFitRunMsgs

 

Returns

a new NcmFitMC.

[transfer full]


ncm_fit_mc_free ()

void
ncm_fit_mc_free (NcmFitMC *mc);

Decrement the reference count atomically by one. If the reference count reaches zero, all memory allocated by the object is released and the object is freed.

Parameters

mc

a NcmFitMC

 

ncm_fit_mc_clear ()

void
ncm_fit_mc_clear (NcmFitMC **mc);

When this function is invoked, it first checks whether *mc is not NULL. If *mc is not NULL, the function reduces the reference count of *mc by one. If the reference count reaches zero, all memory allocated by the object is released, the object is freed, and *mc is set to NULL.

Parameters

mc

a NcmFitMC

 

ncm_fit_mc_set_data_file ()

void
ncm_fit_mc_set_data_file (NcmFitMC *mc,
                          const gchar *filename);

Sets the data file to be used by the NcmMSetCatalog object of mc .

Parameters

mc

a NcmFitMC

 

filename

a filename

 

ncm_fit_mc_set_mtype ()

void
ncm_fit_mc_set_mtype (NcmFitMC *mc,
                      NcmFitRunMsgs mtype);

Sets the run messages type of mc to mtype .

Parameters

mc

a NcmFitMC

 

mtype

a NcmFitRunMsgs

 

ncm_fit_mc_set_rtype ()

void
ncm_fit_mc_set_rtype (NcmFitMC *mc,
                      NcmFitMCResampleType rtype);

Sets the resample type of mc to rtype .

Parameters

mc

a NcmFitMC

 

rtype

a NcmFitMCResampleType

 

ncm_fit_mc_set_nthreads ()

void
ncm_fit_mc_set_nthreads (NcmFitMC *mc,
                         guint nthreads);

Sets the number of threads to be used by mc to nthreads .

Parameters

mc

a NcmFitMC

 

nthreads

number of threads

 

ncm_fit_mc_keep_order ()

void
ncm_fit_mc_keep_order (NcmFitMC *mc,
                       gboolean keep_order);

Sets whether keep the catalog in order of sampling. When performing parallel runs, the catalog is not kept in order of sampling. This is done to avoid the overhead of locking the catalog. If you want to keep the catalog in order of sampling, set this property to TRUE.

Parameters

mc

a NcmFitMC

 

keep_order

whether keep the catalog in order of sampling

 

ncm_fit_mc_set_fiducial ()

void
ncm_fit_mc_set_fiducial (NcmFitMC *mc,
                         NcmMSet *fiduc);

Sets the fiducial model of mc to fiduc . If fiduc is NULL, the fiducial model is set to the model set of the fit object of mc . If fiduc is not NULL, the fiducial model is set to fiduc . If fiduc is not NULL, it must be equal to the model set of the fit object of mc .

Note that in the end of an analysis, the NcmMSet in mc will be equal to the last sampled model set.

Parameters

mc

a NcmFitMC

 

fiduc

a NcmMSet

 

ncm_fit_mc_set_rng ()

void
ncm_fit_mc_set_rng (NcmFitMC *mc,
                    NcmRNG *rng);

Sets the RNG object of mc to rng .

Parameters

mc

a NcmFitMC

 

rng

a NcmRNG

 

ncm_fit_mc_is_running ()

gboolean
ncm_fit_mc_is_running (NcmFitMC *mc);

Checks whether a run is running, that is whether ncm_fit_mc_start_run() was called and ncm_fit_mc_end_run() was not called yet.

Parameters

mc

a NcmFitMC

 

Returns

TRUE if a run is running, FALSE otherwise.


ncm_fit_mc_start_run ()

void
ncm_fit_mc_start_run (NcmFitMC *mc);

Starts a Monte Carlo run. This function will start a Monte Carlo run using the NcmFit object and the NcmMSet object of mc .

This method will not compute the any likelihood. It will only start the run. To compute samples, call ncm_fit_mc_run() or ncm_fit_mc_run_lre() after this function.

To finish the run, call ncm_fit_mc_end_run().

Parameters

mc

a NcmFitMC

 

ncm_fit_mc_end_run ()

void
ncm_fit_mc_end_run (NcmFitMC *mc);

Ends a Monte Carlo run. This function will end a Monte Carlo run using the NcmFit object and the NcmMSet object of mc .

Parameters

mc

a NcmFitMC

 

ncm_fit_mc_reset ()

void
ncm_fit_mc_reset (NcmFitMC *mc);

Resets the Monte Carlo run. This function will reset the Monte Carlo run erase all samples and reset the catalog.

Parameters

mc

a NcmFitMC

 

ncm_fit_mc_set_first_sample_id ()

void
ncm_fit_mc_set_first_sample_id (NcmFitMC *mc,
                                gint first_sample_id);

Sets the first sample id of the Monte Carlo run to first_sample_id . This function will skip all samples until it reaches the first_sample_id .

Parameters

mc

a NcmFitMC

 

first_sample_id

first sample id

 

ncm_fit_mc_run ()

void
ncm_fit_mc_run (NcmFitMC *mc,
                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

mc

a NcmFitMC

 

n

total number of realizations to run

 

ncm_fit_mc_run_lre ()

void
ncm_fit_mc_run_lre (NcmFitMC *mc,
                    guint prerun,
                    gdouble lre);

Runs the Monte Carlo until the largest relative error considering the erros on the parameter means is less than lre .

Parameters

mc

a NcmFitMC

 

prerun

number of pre-runs

 

lre

largest relative error

 

ncm_fit_mc_mean_covar ()

void
ncm_fit_mc_mean_covar (NcmFitMC *mc);

Computes the mean and covariance of the Monte Carlo run. The mean and covariance are stored in the NcmFit object of mc . The mean is stored in the NcmFitState object of the NcmFit object and in the NcmMSetCatalog object of mc .

Parameters

mc

a NcmFitMC

 

ncm_fit_mc_get_catalog ()

NcmMSetCatalog *
ncm_fit_mc_get_catalog (NcmFitMC *mc);

Gets the generated catalog of mc .

Parameters

mc

a NcmFitMC

 

Returns

the generated catalog.

[transfer full]


ncm_fit_mc_peek_catalog ()

NcmMSetCatalog *
ncm_fit_mc_peek_catalog (NcmFitMC *mc);

Peeks the generated catalog of mc .

Parameters

mc

a NcmFitMC

 

Returns

the generated catalog.

[transfer none]

Types and Values

NCM_TYPE_FIT_MC

#define NCM_TYPE_FIT_MC (ncm_fit_mc_get_type ())

enum NcmFitMCResampleType

Montecarlo resample options

Members

NCM_FIT_MC_RESAMPLE_FROM_MODEL

Montecarlo resampling from models

 

NCM_FIT_MC_RESAMPLE_BOOTSTRAP_NOMIX

Montecarlo bootstraping each NcmData separately.

 

NCM_FIT_MC_RESAMPLE_BOOTSTRAP_MIX

Montecarlo bootstraping mixing all NcmData in the bootstrap process.

 

NCM_FIT_MC_MIN_SYNC_INTERVAL

#define NCM_FIT_MC_MIN_SYNC_INTERVAL (10.0)

NcmFitMC

typedef struct _NcmFitMC NcmFitMC;

Property Details

The “fiducial” property

  “fiducial”                 NcmMSet *

Fiducial model to sample from.

Owner: NcmFitMC

Flags: Read / Write / Construct


The “fit” property

  “fit”                      NcmFit *

Fit object.

Owner: NcmFitMC

Flags: Read / Write / Construct Only


The “keep-order” property

  “keep-order”               gboolean

Whether keep the catalog in order of sampling.

Owner: NcmFitMC

Flags: Read / Write / Construct

Default value: TRUE


The “mtype” property

  “mtype”                    NcmFitRunMsgs

Run messages type.

Owner: NcmFitMC

Flags: Read / Write

Default value: NCM_FIT_RUN_MSGS_SIMPLE


The “nthreads” property

  “nthreads”                 guint

Number of threads to run.

Owner: NcmFitMC

Flags: Read / Write

Allowed values: <= 100

Default value: 0


The “rtype” property

  “rtype”                    NcmFitMCResampleType

Monte Carlo run type.

Owner: NcmFitMC

Flags: Read / Write / Construct

Default value: NCM_FIT_MC_RESAMPLE_FROM_MODEL