NcmLikelihood

NcmLikelihood — Likelihood combining a NcmDataset and priors.

Functions

Properties

NcmDataset * dataset Read / Write / Construct
NcmVector * m2lnL-v Read / Write
NcmObjArray * priors-f Read / Write
NcmObjArray * priors-m2lnL Read / Write

Types and Values

Object Hierarchy

    GObject
    ╰── NcmLikelihood

Description

Class combining a NcmDataset and priors. It represents the posterior distribution of the parameters of a model given the data and the priors. For historical reasons it is called likelihood, but it is actually the posterior distribution. This will be fixed in version 1.0 but for backward compatibility for version 0 it will remain as likelihood.

The posterior distribution is the combination of the NcmDataset containing the individual likelihoods of the data and the priors. The priors are defined as NcmPrior objects. The priors can be leastsquares priors or m2lnL priors. The leastsquares priors compute the leastsquares vectors $\vec{f}_i$ and the m2lnL priors the probabilities $-2\ln P_{\mathrm{prior},i}$.

The final posterior distribution is defined as: \begin{equation} -2\ln P_{\mathrm{posterior}} = -2\ln L_{\mathrm{data}} + \sum_i \vec{f}_i\cdot\vec{f}_i + \sum_i -2\ln P_{\mathrm{prior},i} \end{equation}

Note that to be able to use least squares the posterior must contain least-squares priors only and all individual likelihoods in the NcmDataset must also be least-squares.

Functions

ncm_likelihood_new ()

NcmLikelihood *
ncm_likelihood_new (NcmDataset *dset);

Creates a new NcmLikelihood for the given NcmDataset.

Parameters

dset

a NcmDataset.

 

Returns

A new NcmLikelihood.

[transfer full]


ncm_likelihood_ref ()

NcmLikelihood *
ncm_likelihood_ref (NcmLikelihood *lh);

Increases the reference count of the object.

Parameters

lh

a NcmLikelihood

 

Returns

The same object lh .

[transfer full]


ncm_likelihood_dup ()

NcmLikelihood *
ncm_likelihood_dup (NcmLikelihood *lh,
                    NcmSerialize *ser);

Duplicates the object and all of its content.

Parameters

lh

a NcmLikelihood.

 

ser

a NcmSerialize.

 

Returns

A duplicate of lh .

[transfer full]


ncm_likelihood_free ()

void
ncm_likelihood_free (NcmLikelihood *lh);

Decreases the reference count of the object. If the reference count reaches zero, the object is finalized (i.e. its memory is freed).

Parameters

lh

a NcmLikelihood

 

ncm_likelihood_clear ()

void
ncm_likelihood_clear (NcmLikelihood **lh);

If *lh is not NULL, decreases the reference count of the object and sets *lh to NULL.

Parameters

lh

a NcmLikelihood

 

ncm_likelihood_peek_dataset ()

NcmDataset *
ncm_likelihood_peek_dataset (NcmLikelihood *lh);

Gets the NcmDataset associated with the NcmLikelihood.

Parameters

lh

a NcmLikelihood

 

Returns

the NcmDataset associated with the NcmLikelihood.

[transfer none]


ncm_likelihoood_peek_m2lnL_v ()

NcmVector *
ncm_likelihoood_peek_m2lnL_v (NcmLikelihood *lh);

Gets the m2lnL vector associated with the NcmLikelihood containing the last calculated m2lnL values.

Parameters

lh

a NcmLikelihood

 

Returns

the m2lnL vector associated with the NcmLikelihood.

[transfer none]


ncm_likelihood_priors_add ()

void
ncm_likelihood_priors_add (NcmLikelihood *lh,
                           NcmPrior *prior);

Adds a NcmPrior to the NcmLikelihood.

Parameters

lh

a NcmLikelihood

 

prior

a NcmPrior

 

ncm_likelihood_priors_take ()

void
ncm_likelihood_priors_take (NcmLikelihood *lh,
                            NcmPrior *prior);

Adds a NcmPrior to the NcmLikelihood and takes ownership of the object.

Parameters

lh

a NcmLikelihood.

[in][transfer full]

prior

a NcmPrior

 

ncm_likelihood_priors_peek_f ()

NcmPrior *
ncm_likelihood_priors_peek_f (NcmLikelihood *lh,
                              guint i);

Peeks the prior at index i in the NcmLikelihood from the array of priors that contribute to the leastsquares f.

Parameters

lh

a NcmLikelihood

 

i

prior index

 

Returns

a NcmPrior representing the prior at index i .

[transfer none]


ncm_likelihood_priors_length_f ()

guint
ncm_likelihood_priors_length_f (NcmLikelihood *lh);

Gets the number of priors that contribute to the leastsquares f.

Parameters

lh

a NcmLikelihood

 

Returns

the number of priors that contribute to the leastsquares f.


ncm_likelihood_priors_peek_m2lnL ()

NcmPrior *
ncm_likelihood_priors_peek_m2lnL (NcmLikelihood *lh,
                                  guint i);

Peek the prior at index i in the NcmLikelihood from the array of priors that contribute to the m2lnL.

Parameters

lh

a NcmLikelihood

 

i

prior index

 

Returns

a NcmPrior representing the prior at index i .

[transfer none]


ncm_likelihood_priors_length_m2lnL ()

guint
ncm_likelihood_priors_length_m2lnL (NcmLikelihood *lh);

Gets the number of priors that contribute to the m2lnL.

Parameters

lh

a NcmLikelihood

 

Returns

the number of priors that contribute to the m2lnL.


ncm_likelihood_priors_leastsquares_f ()

void
ncm_likelihood_priors_leastsquares_f (NcmLikelihood *lh,
                                      NcmMSet *mset,
                                      NcmVector *priors_f);

Calculates the leastsquares f for the priors, note that the all priors in lh must be priors that contribute to the leastsquares f.

Parameters

lh

a NcmLikelihood.

 

mset

a NcmMSet.

 

priors_f

a NcmVector.

 

ncm_likelihood_leastsquares_f ()

void
ncm_likelihood_leastsquares_f (NcmLikelihood *lh,
                               NcmMSet *mset,
                               NcmVector *f);

Combines the leastsquares f for the dataset and the priors, note that the first elements of f are the leastsquares f for the dataset and the last elements are the leastsquares f for the priors.

Parameters

lh

a NcmLikelihood.

 

mset

a NcmMSet.

 

f

a NcmVector.

 

ncm_likelihood_priors_m2lnL_val ()

void
ncm_likelihood_priors_m2lnL_val (NcmLikelihood *lh,
                                 NcmMSet *mset,
                                 gdouble *priors_m2lnL);

Combines the m2lnL for the priors, note that the priors can be priors that contribute to the leastsquares f or to the m2lnL.

Parameters

lh

a NcmLikelihood.

 

mset

a NcmMSet.

 

priors_m2lnL

the sum of the priors m2lnL.

[out]

ncm_likelihood_priors_m2lnL_vec ()

void
ncm_likelihood_priors_m2lnL_vec (NcmLikelihood *lh,
                                 NcmMSet *mset,
                                 NcmVector *priors_m2lnL_v);

Computes the m2lnL for the priors, inserting the result in priors_m2lnL_v . The order of the elements in priors_m2lnL_v is the same as the order of the priors in the NcmLikelihood. The first elements are the m2lnL for the priors that contribute to the leastsquares f and the last elements are the m2lnL for the priors that contribute to the m2lnL.

Parameters

lh

a NcmLikelihood.

 

mset

a NcmMSet.

 

priors_m2lnL_v

a NcmVector

 

ncm_likelihood_m2lnL_val ()

void
ncm_likelihood_m2lnL_val (NcmLikelihood *lh,
                          NcmMSet *mset,
                          gdouble *m2lnL);

Combines the m2lnL for the dataset and the priors, note that the priors can be priors that contribute to the leastsquares f or to the m2lnL.

Parameters

lh

a NcmLikelihood.

 

mset

a NcmMSet.

 

m2lnL

the sum of the m2lnL.

[out]

Types and Values

NCM_TYPE_LIKELIHOOD

#define NCM_TYPE_LIKELIHOOD (ncm_likelihood_get_type ())

NcmLikelihood

typedef struct _NcmLikelihood NcmLikelihood;

Property Details

The “dataset” property

  “dataset”                  NcmDataset *

Dataset object.

Owner: NcmLikelihood

Flags: Read / Write / Construct


The “m2lnL-v” property

  “m2lnL-v”                  NcmVector *

m2lnL vector.

Owner: NcmLikelihood

Flags: Read / Write


The “priors-f” property

  “priors-f”                 NcmObjArray *

Priors f array.

Owner: NcmLikelihood

Flags: Read / Write


The “priors-m2lnL” property

  “priors-m2lnL”             NcmObjArray *

Priors m2lnL array.

Owner: NcmLikelihood

Flags: Read / Write