NcmFit

NcmFit — Abstract class for implementing fitting methods.

Functions

void (*_NcmFitLSJ) ()
void (*_NcmFitLSFJ) ()
void (*_NcmFitM2lnLGrad) ()
void (*_NcmFitM2lnLValGrad) ()
void (*NcmFitWriter) ()
void (*NcmFitUpdater) ()
void (*NcmFitUpdateChange) ()
NcmFit * ncm_fit_factory ()
NcmFit * ncm_fit_ref ()
NcmFit * ncm_fit_copy_new ()
NcmFit * ncm_fit_dup ()
void ncm_fit_free ()
void ncm_fit_clear ()
void ncm_fit_set_sub_fit ()
NcmFit * ncm_fit_get_sub_fit ()
gboolean ncm_fit_has_sub_fit ()
void ncm_fit_set_grad_type ()
void ncm_fit_set_maxiter ()
void ncm_fit_set_m2lnL_reltol ()
void ncm_fit_set_m2lnL_abstol ()
void ncm_fit_set_params_reltol ()
void ncm_fit_set_messages ()
NcmFitGradType ncm_fit_get_grad_type ()
guint ncm_fit_get_maxiter ()
gdouble ncm_fit_get_m2lnL_reltol ()
gdouble ncm_fit_get_m2lnL_abstol ()
gdouble ncm_fit_get_params_reltol ()
NcmFitRunMsgs ncm_fit_get_messages ()
gboolean ncm_fit_is_least_squares ()
NcmMSet * ncm_fit_peek_mset ()
NcmFitState * ncm_fit_peek_state ()
NcmLikelihood * ncm_fit_peek_likelihood ()
NcmDiff * ncm_fit_peek_diff ()
void ncm_fit_params_set ()
void ncm_fit_params_set_vector ()
void ncm_fit_params_set_vector_offset ()
void ncm_fit_params_set_array ()
void ncm_fit_params_set_gsl_vector ()
void ncm_fit_params_update ()
void ncm_fit_add_equality_constraint ()
void ncm_fit_add_inequality_constraint ()
void ncm_fit_remove_equality_constraints ()
void ncm_fit_remove_inequality_constraints ()
guint ncm_fit_equality_constraints_len ()
guint ncm_fit_inequality_constraints_len ()
void ncm_fit_get_equality_constraint ()
void ncm_fit_get_inequality_constraint ()
const gchar * ncm_fit_get_desc ()
void ncm_fit_set_logger ()
void ncm_fit_log_info ()
void ncm_fit_log_covar ()
void ncm_fit_log_start ()
void ncm_fit_log_state ()
void ncm_fit_log_step ()
void ncm_fit_log_step_error ()
void ncm_fit_log_end ()
void ncm_fit_data_m2lnL_val ()
void ncm_fit_priors_m2lnL_val ()
void ncm_fit_m2lnL_val ()
void ncm_fit_ls_f ()
void ncm_fit_m2lnL_grad ()
void ncm_fit_m2lnL_val_grad ()
void ncm_fit_ls_J ()
void ncm_fit_ls_f_J ()
void ncm_fit_obs_fisher ()
void ncm_fit_ls_fisher ()
void ncm_fit_fisher ()
NcmVector * ncm_fit_fisher_bias ()
void ncm_fit_numdiff_m2lnL_covar ()
gdouble ncm_fit_numdiff_m2lnL_lndet_covar ()
NcmMatrix * ncm_fit_get_covar ()
gdouble ncm_fit_covar_var ()
gdouble ncm_fit_covar_sd ()
gdouble ncm_fit_covar_cov ()
gdouble ncm_fit_covar_cor ()
gdouble ncm_fit_covar_fparam_var ()
gdouble ncm_fit_covar_fparam_sd ()
gdouble ncm_fit_covar_fparam_cov ()
gdouble ncm_fit_covar_fparam_cor ()
void ncm_fit_reset ()
gboolean ncm_fit_run ()
gboolean ncm_fit_run_restart ()
NcmMatrix * ncm_fit_lr_test_range ()
gdouble ncm_fit_lr_test ()
gdouble ncm_fit_chisq_test ()
void ncm_fit_function_error ()

Properties

NcmObjArray * equality-constraints Read / Write
NcmVector * equality-constraints-tot Read / Write
NcmFitGradType grad-type Read / Write / Construct
NcmObjArray * inequality-constraints Read / Write
NcmVector * inequality-constraints-tot Read / Write
NcmLikelihood * likelihood Read / Write / Construct Only
double m2lnL-abstol Read / Write / Construct
double m2lnL-reltol Read / Write / Construct
guint maxiter Read / Write / Construct
NcmMSet * mset Read / Write / Construct Only
double params-reltol Read / Write / Construct
NcmFitState * state Read / Write / Construct Only
NcmFit * sub-fit Read / Write

Types and Values

Object Hierarchy

    GEnum
    ├── NcmFitGradType
    ├── NcmFitRunMsgs
    ╰── NcmFitType
    GObject
    ╰── NcmFit
        ├── NcmFitGSLLS
        ├── NcmFitGSLMM
        ├── NcmFitGSLMMS
        ├── NcmFitLevmar
        ╰── NcmFitNLOpt

Description

This object implements a abstract class for implementing fitting methods.

Functions

_NcmFitLSJ ()

void
(*_NcmFitLSJ) (NcmFit *fit,
               NcmMatrix *J);

_NcmFitLSFJ ()

void
(*_NcmFitLSFJ) (NcmFit *fit,
                NcmVector *f,
                NcmMatrix *J);

_NcmFitM2lnLGrad ()

void
(*_NcmFitM2lnLGrad) (NcmFit *fit,
                     NcmVector *grad);

_NcmFitM2lnLValGrad ()

void
(*_NcmFitM2lnLValGrad) (NcmFit *fit,
                        gdouble *m2lnL,
                        NcmVector *grad);

NcmFitWriter ()

void
(*NcmFitWriter) (NcmFit *fit,
                 const gchar *msg);

NcmFitUpdater ()

void
(*NcmFitUpdater) (NcmFit *fit,
                  guint n);

NcmFitUpdateChange ()

void
(*NcmFitUpdateChange) (NcmFit *fit,
                       const gchar *msg);

ncm_fit_factory ()

NcmFit *
ncm_fit_factory (NcmFitType ftype,
                 gchar *algo_name,
                 NcmLikelihood *lh,
                 NcmMSet *mset,
                 NcmFitGradType gtype);

Creates a new NcmFit object.

Parameters

ftype

a NcmFitType

 

algo_name

name of the algorithm to be used.

[nullable]

lh

a NcmLikelihood

 

mset

a NcmMSet

 

gtype

a NcmFitGradType

 

Returns

a new NcmFit object.

[transfer full]


ncm_fit_ref ()

NcmFit *
ncm_fit_ref (NcmFit *fit);

Increases the reference count of fit .

Parameters

fit

a NcmFit

 

Returns

fit .

[transfer full]


ncm_fit_copy_new ()

NcmFit *
ncm_fit_copy_new (NcmFit *fit,
                  NcmLikelihood *lh,
                  NcmMSet *mset,
                  NcmFitGradType gtype);

Duplicates the NcmFit object with new references for its contents.

Parameters

fit

a NcmFit

 

lh

a NcmLikelihood

 

mset

a NcmMSet

 

gtype

a NcmFitGradType

 

Returns

Copy of fit .

[transfer full]


ncm_fit_dup ()

NcmFit *
ncm_fit_dup (NcmFit *fit,
             NcmSerialize *ser);

Duplicates the NcmFit object duplicating all its contents.

Parameters

fit

a NcmFit

 

ser

a NcmSerialize

 

Returns

Duplicate of fit .

[transfer full]


ncm_fit_free ()

void
ncm_fit_free (NcmFit *fit);

Atomically decrements the reference count of fit by one. If the reference count drops to 0, all memory allocated by fit is released.

Parameters

fit

a NcmFit

 

ncm_fit_clear ()

void
ncm_fit_clear (NcmFit **fit);

The reference count of fit is decreased and the pointer is set to NULL.

Parameters

fit

a NcmFit

 

ncm_fit_set_sub_fit ()

void
ncm_fit_set_sub_fit (NcmFit *fit,
                     NcmFit *sub_fit);

Sets a NcmFit object to be used as subsidiary fit.

Parameters

fit

a NcmFit

 

sub_fit

a NcmFit

 

ncm_fit_get_sub_fit ()

NcmFit *
ncm_fit_get_sub_fit (NcmFit *fit);

Gets a NcmFit object to be used as subsidiary fit.

Parameters

fit

a NcmFit

 

Returns

a NcmFit object.

[transfer full]


ncm_fit_has_sub_fit ()

gboolean
ncm_fit_has_sub_fit (NcmFit *fit);

Checks if fit has a subsidiary fit.

Parameters

fit

a NcmFit

 

Returns

TRUE if fit has a subsidiary fit, FALSE otherwise.


ncm_fit_set_grad_type ()

void
ncm_fit_set_grad_type (NcmFit *fit,
                       NcmFitGradType gtype);

Sets the differentiation method to be used.

Parameters

fit

a NcmLikelihood

 

gtype

a NcmFitGradType

 

ncm_fit_set_maxiter ()

void
ncm_fit_set_maxiter (NcmFit *fit,
                     guint maxiter);

Sets the maximum number of iterations.

Parameters

fit

a NcmFit

 

maxiter

maximum number of interations

 

ncm_fit_set_m2lnL_reltol ()

void
ncm_fit_set_m2lnL_reltol (NcmFit *fit,
                          gdouble tol);

Sets the relative tolerance for the m2lnL.

Parameters

fit

a NcmFit

 

tol

relative tolarance

 

ncm_fit_set_m2lnL_abstol ()

void
ncm_fit_set_m2lnL_abstol (NcmFit *fit,
                          gdouble tol);

Sets the absolute tolerance for the m2lnL.

Parameters

fit

a NcmFit

 

tol

absolute tolerance

 

ncm_fit_set_params_reltol ()

void
ncm_fit_set_params_reltol (NcmFit *fit,
                           gdouble tol);

Sets the relative tolerance for the fitted parameters.

Parameters

fit

a NcmFit

 

tol

relative tolerance

 

ncm_fit_set_messages ()

void
ncm_fit_set_messages (NcmFit *fit,
                      NcmFitRunMsgs mtype);

Sets the log level for the messages to be printed during the fit.

Parameters

fit

a NcmFit

 

mtype

a NcmFitRunMsgs

 

ncm_fit_get_grad_type ()

NcmFitGradType
ncm_fit_get_grad_type (NcmFit *fit);

Gets the differentiation method to be used.

Parameters

fit

a NcmFit

 

ncm_fit_get_maxiter ()

guint
ncm_fit_get_maxiter (NcmFit *fit);

Gets the maximum number of iterations.

Parameters

fit

a NcmFit.

 

Returns

a integer (maxiter) that corresponds to the maximum number of iterations.


ncm_fit_get_m2lnL_reltol ()

gdouble
ncm_fit_get_m2lnL_reltol (NcmFit *fit);

Gets the relative tolerance for the m2lnL.

Parameters

fit

a NcmFit

 

Returns

the relative tolerance (double).


ncm_fit_get_m2lnL_abstol ()

gdouble
ncm_fit_get_m2lnL_abstol (NcmFit *fit);

Gets the absolute tolerance for the m2lnL.

Parameters

fit

a NcmFit

 

Returns

the absolute tolerance (double).


ncm_fit_get_params_reltol ()

gdouble
ncm_fit_get_params_reltol (NcmFit *fit);

Gets the relative tolerance for the fitted parameters.

Parameters

fit

a NcmFit

 

Returns

the relative tolerance (double).


ncm_fit_get_messages ()

NcmFitRunMsgs
ncm_fit_get_messages (NcmFit *fit);

Gets the log level for the messages to be printed during the fit.

Parameters

fit

a NcmFit

 

Returns

a NcmFitRunMsgs.


ncm_fit_is_least_squares ()

gboolean
ncm_fit_is_least_squares (NcmFit *fit);

Indicates if the least squares fitting is being used (TRUE) or not (FALSE).

Parameters

fit

a NcmFit

 

Returns

whenever the fit object use a least squares method.


ncm_fit_peek_mset ()

NcmMSet *
ncm_fit_peek_mset (NcmFit *fit);

Peeks the NcmMSet object.

Parameters

fit

a NcmFit

 

Returns

a NcmMSet object.

[transfer none]


ncm_fit_peek_state ()

NcmFitState *
ncm_fit_peek_state (NcmFit *fit);

Peeks the NcmFitState object.

Parameters

fit

a NcmFit

 

Returns

a NcmFitState object.

[transfer none]


ncm_fit_peek_likelihood ()

NcmLikelihood *
ncm_fit_peek_likelihood (NcmFit *fit);

Peeks the NcmLikelihood object.

Parameters

fit

a NcmFit

 

Returns

a NcmLikelihood object.

[transfer none]


ncm_fit_peek_diff ()

NcmDiff *
ncm_fit_peek_diff (NcmFit *fit);

Peeks the NcmDiff object.

Parameters

fit

a NcmFit

 

Returns

a NcmDiff object.

[transfer none]


ncm_fit_params_set ()

void
ncm_fit_params_set (NcmFit *fit,
                    guint i,
                    const gdouble x);

Sets the parameters vector.

Parameters

fit

a NcmFit

 

i

the parameter index

 

x

a double

 

ncm_fit_params_set_vector ()

void
ncm_fit_params_set_vector (NcmFit *fit,
                           NcmVector *x);

Sets the parameters vector.

Parameters

fit

a NcmFit

 

x

a NcmVector

 

ncm_fit_params_set_vector_offset ()

void
ncm_fit_params_set_vector_offset (NcmFit *fit,
                                  NcmVector *x,
                                  guint offset);

Sets the parameters from vector x starting at offset .

Parameters

fit

a NcmFit

 

x

a NcmVector

 

offset

offset

 

ncm_fit_params_set_array ()

void
ncm_fit_params_set_array (NcmFit *fit,
                          const gdouble *x);

Sets the parameters from array x .

Parameters

fit

a NcmFit

 

x

an array of gdoubles.

[in][array][element-type gdouble]

ncm_fit_params_set_gsl_vector ()

void
ncm_fit_params_set_gsl_vector (NcmFit *fit,
                               const gsl_vector *x);

Sets the parameters from a gsl_vector x .

[skip]

Parameters

fit

a NcmFit

 

x

a gsl_vector

 

ncm_fit_params_update ()

void
ncm_fit_params_update (NcmFit *fit);

Updates the parameters vector.

Parameters

fit

a NcmFit

 

ncm_fit_add_equality_constraint ()

void
ncm_fit_add_equality_constraint (NcmFit *fit,
                                 NcmMSetFunc *func,
                                 const gdouble tot);

Adds an equality constraint with the function func and the tolerance tot .

Parameters

fit

a NcmFit

 

func

a NcmMSetFunc

 

tot

tolerance

 

ncm_fit_add_inequality_constraint ()

void
ncm_fit_add_inequality_constraint (NcmFit *fit,
                                   NcmMSetFunc *func,
                                   const gdouble tot);

Adds an inequality constraint with the function func and the tolerance tot .

Parameters

fit

a NcmFit

 

func

a NcmMSetFunc

 

tot

tolerance

 

ncm_fit_remove_equality_constraints ()

void
ncm_fit_remove_equality_constraints (NcmFit *fit);

Removes all equality constraints.

Parameters

fit

a NcmFit

 

ncm_fit_remove_inequality_constraints ()

void
ncm_fit_remove_inequality_constraints (NcmFit *fit);

Removes all inequality constraints.

Parameters

fit

a NcmFit

 

ncm_fit_equality_constraints_len ()

guint
ncm_fit_equality_constraints_len (NcmFit *fit);

Gets the number of equality constraints.

Parameters

fit

a NcmFit

 

Returns

the number of equality constraints.


ncm_fit_inequality_constraints_len ()

guint
ncm_fit_inequality_constraints_len (NcmFit *fit);

Gets the number of inequality constraints.

Parameters

fit

a NcmFit

 

Returns

the number of inequality constraints.


ncm_fit_get_equality_constraint ()

void
ncm_fit_get_equality_constraint (NcmFit *fit,
                                 guint i,
                                 NcmMSetFunc **func,
                                 gdouble *tot);

Gets the equality constraint at index i .

Parameters

fit

a NcmFit

 

i

index of the equality constraint

 

func

a NcmMSetFunc.

[out][transfer none]

tot

a double.

[out]

ncm_fit_get_inequality_constraint ()

void
ncm_fit_get_inequality_constraint (NcmFit *fit,
                                   guint i,
                                   NcmMSetFunc **func,
                                   gdouble *tot);

Gets the inequality constraint at index i .

Parameters

fit

a NcmFit

 

i

index of the inequality constraint

 

func

a NcmMSetFunc.

[out][transfer none]

tot

a double.

[out]

ncm_fit_get_desc ()

const gchar *
ncm_fit_get_desc (NcmFit *fit);

Gets the fit object description.

Parameters

fit

a NcmFit

 

Returns

fit object description.

[transfer none]


ncm_fit_set_logger ()

void
ncm_fit_set_logger (NcmFit *fit,
                    NcmFitWriter writer,
                    NcmFitUpdater updater,
                    NcmFitUpdateChange start_update,
                    NcmFitUpdateChange end_update);

Sets the logger functions. The writer function is called to write the messages to the log. The updater function is called to update the parameters. The start_update is called before the minimization starts and the end_update is called after the minimization ends.

Parameters

fit

a NcmFit

 

writer

a NcmFitWriter.

[scope notified]

updater

a NcmFitUpdater.

[scope notified]

start_update

a NcmFitUpdateChange.

[scope notified][nullable]

end_update

a NcmFitUpdateChange.

[scope notified][nullable]

ncm_fit_log_info ()

void
ncm_fit_log_info (NcmFit *fit);

Prints to the log the data set and the model set.

Parameters

fit

a NcmFit

 

ncm_fit_log_covar ()

void
ncm_fit_log_covar (NcmFit *fit);

Prints to the log file the names and indices of the fitted parameters, their best-fit values, standard deviations and correlation matrix.

Parameters

fit

a NcmFit

 

ncm_fit_log_start ()

void
ncm_fit_log_start (NcmFit *fit);

This function prints in the log the initial state.

Parameters

fit

a NcmFit

 

ncm_fit_log_state ()

void
ncm_fit_log_state (NcmFit *fit);

This function prints in the log the current state.

Parameters

fit

a NcmFit

 

ncm_fit_log_step ()

void
ncm_fit_log_step (NcmFit *fit);

This function prints in the log one step of the minimization.

Parameters

fit

a NcmFit

 

ncm_fit_log_step_error ()

void
ncm_fit_log_step_error (NcmFit *fit,
                        const gchar *strerror,
                        ...);

This function prints in the log the error message.

Parameters

fit

a NcmFit

 

strerror

error message

 

...

arguments

 

ncm_fit_log_end ()

void
ncm_fit_log_end (NcmFit *fit);

This function prints in the log the precision with which the best-fit was found.

Parameters

fit

a NcmFit

 

ncm_fit_data_m2lnL_val ()

void
ncm_fit_data_m2lnL_val (NcmFit *fit,
                        gdouble *data_m2lnL);

This function computes minus two times the logarithm base e of the likelihood using only the data set and not considering any prior. The result is set on data_m2lnL .

Parameters

fit

a NcmFit

 

data_m2lnL

minus two times the logarithm base e of the likelihood.

[out]

ncm_fit_priors_m2lnL_val ()

void
ncm_fit_priors_m2lnL_val (NcmFit *fit,
                          gdouble *priors_m2lnL);

This function computes minus two times the logarithm base e of the likelihood using the data set and taking into account the assumed priors. The result is set on priors_m2lnL .

Parameters

fit

a NcmFit

 

priors_m2lnL

minus two times the logarithm base e of the likelihood.

[out]

ncm_fit_m2lnL_val ()

void
ncm_fit_m2lnL_val (NcmFit *fit,
                   gdouble *m2lnL);

Computes minus two times the logarithm base e of the likelihood.

Parameters

fit

a NcmFit

 

m2lnL

minus two times the logarithm base e of the likelihood.

[out]

ncm_fit_ls_f ()

void
ncm_fit_ls_f (NcmFit *fit,
              NcmVector *f);

Computes the residuals vector.

Parameters

fit

a NcmFit

 

f

a NcmVector

 

ncm_fit_m2lnL_grad ()

void
ncm_fit_m2lnL_grad (NcmFit *fit,
                    NcmVector *df);

Computes the gradient of the minus two times the logarithm base e of the likelihood.

Parameters

fit

a NcmFit

 

df

a NcmVector

 

ncm_fit_m2lnL_val_grad ()

void
ncm_fit_m2lnL_val_grad (NcmFit *fit,
                        gdouble *result,
                        NcmVector *df);

Computes the minus two times the logarithm base e of the likelihood and its gradient.

Parameters

fit

a NcmFit

 

result

the minus two times the logarithm base e of the likelihood.

[out]

df

a NcmVector

 

ncm_fit_ls_J ()

void
ncm_fit_ls_J (NcmFit *fit,
              NcmMatrix *J);

Computes the Jacobian matrix for the least squares problem.

Parameters

fit

a NcmFit

 

J

a NcmMatrix

 

ncm_fit_ls_f_J ()

void
ncm_fit_ls_f_J (NcmFit *fit,
                NcmVector *f,
                NcmMatrix *J);

Computes the residuals vector and the Jacobian matrix for the least squares problem.

Parameters

fit

a NcmFit

 

f

a NcmVector

 

J

a NcmMatrix

 

ncm_fit_obs_fisher ()

void
ncm_fit_obs_fisher (NcmFit *fit);

Computes the covariance matrix using the inverse of the Hessian matrix $\partial_i\partial_j -\ln(L)$, where the derivatives are taken with respect to the free parameters. This function does not use the gradient defined in the fit object, it always uses the accurate numerical differentiation methods implemented in the NcmDiff object.

It sets both the covariance matrix and the Hessian matrix in the NcmFitState object associated to the fit object.

Parameters

fit

a NcmFit

 

ncm_fit_ls_fisher ()

void
ncm_fit_ls_fisher (NcmFit *fit);

Computes the covariance matrix using the jacobian matrix and the least squares problem, see ncm_fit_ls_J(). Note that this function uses the gradient defined in the fit object using ncm_fit_set_grad_type() to compute the jacobian matrix.

This function is similar to ncm_fit_fisher() but it computes the covariance using the full jacobian matrix instead adding the individual contributions of each NcmData in the data set.

It sets both the covariance matrix in the NcmFitState object associated to the fit object.

Parameters

fit

a NcmFit

 

ncm_fit_fisher ()

void
ncm_fit_fisher (NcmFit *fit);

Calculates the covariance from the Fisher matrix, see ncm_dataset_fisher_matrix(). Note that this function does not use the gradient defined in the fit object, it always uses the accurate numerical differentiation methods implemented in the NcmDiff object.

It sets both the covariance matrix in the NcmFitState object associated to the fit object.

Parameters

fit

a NcmFit

 

ncm_fit_fisher_bias ()

NcmVector *
ncm_fit_fisher_bias (NcmFit *fit,
                     NcmVector *f_true);

Calculates the covariance from the Fisher matrix and the bias vector, see ncm_dataset_fisher_matrix_bias(). The bias vector is calculated using the the theory vector f_true as the true model expectation values.

Note that this function does not use the gradient defined in the fit object, it always uses the accurate numerical differentiation methods implemented in the NcmDiff object.

It sets the covariance matrix in the NcmFitState object associated to the fit object. Moreover, it computes the final bias vector, that is, the inverse of the Fisher matrix times the bias vector returns it.

Parameters

fit

a NcmFit

 

f_true

a NcmVector

 

Returns

the bias vector.

[transfer full]


ncm_fit_numdiff_m2lnL_covar ()

void
ncm_fit_numdiff_m2lnL_covar (NcmFit *fit);

ncm_fit_numdiff_m2lnL_covar has been deprecated since version 0.18.2 and should not be used in newly-written code.

Use ncm_fit_obs_fisher() instead.

Calcualtes the covariance matrix using the inverse of the Hessian matrix $\partial_i\partial_j -\ln(L)$, where the derivatives are taken with respect to the free parameters.

Parameters

fit

a NcmFit

 

ncm_fit_numdiff_m2lnL_lndet_covar ()

gdouble
ncm_fit_numdiff_m2lnL_lndet_covar (NcmFit *fit);

Calculates the logarithm of the determinant of the covariance matrix using the inverse of the Hessian matrix $\partial_i\partial_j -\ln(L)$, where the derivatives are taken with respect to the free parameters.

It sets the covariance matrix in the NcmFitState object associated to the fit object.

Parameters

fit

a NcmFit

 

Returns

the logarithm of the determinant of the covariance matrix.


ncm_fit_get_covar ()

NcmMatrix *
ncm_fit_get_covar (NcmFit *fit);

Returns a copy of the covariance matrix (pre-calculated by, e.g, ncm_fit_numdiff_m2lnL_covar()).

Parameters

fit

a NcmFit

 

Returns

the covariance matrix.

[transfer full]


ncm_fit_covar_var ()

gdouble
ncm_fit_covar_var (NcmFit *fit,
                   NcmModelID mid,
                   guint pid);

Computes the variance of the fitted parameter pid of the model mid .

Parameters

fit

a NcmFit

 

mid

a NcmModelID

 

pid

the parameter's index of the model mid (integer)

 

Returns

the variance of the fitted parameter pid


ncm_fit_covar_sd ()

gdouble
ncm_fit_covar_sd (NcmFit *fit,
                  NcmModelID mid,
                  guint pid);

Computes the standard deviation of the fitted parameter pid of the model mid .

Parameters

fit

a NcmFit

 

mid

a NcmModelID

 

pid

the parameter's index of the model mid (integer)

 

Returns

the standard deviation of the fitted parameter pid


ncm_fit_covar_cov ()

gdouble
ncm_fit_covar_cov (NcmFit *fit,
                   NcmModelID mid1,
                   guint pid1,
                   NcmModelID mid2,
                   guint pid2);

Computes the covariance between the parameters pid1 and pid2 of the models mid1 and mid2 , respectively.

Parameters

fit

a NcmFit

 

mid1

a NcmModelID

 

pid1

the parameter's index of the model mid1 (integer)

 

mid2

a NcmModelID

 

pid2

the parameter's index of the model mid1 (integer)

 

Returns

the covariance between pid1 and pid2


ncm_fit_covar_cor ()

gdouble
ncm_fit_covar_cor (NcmFit *fit,
                   NcmModelID mid1,
                   guint pid1,
                   NcmModelID mid2,
                   guint pid2);

Computes the correlation between the parameters pid1 and pid2 of the models mid1 and mid2 , respectively.

Parameters

fit

a NcmFit

 

mid1

a NcmModelID

 

pid1

the parameter's index of the model mid1 (integer)

 

mid2

a NcmModelID

 

pid2

the parameter's index of the model mid1 (integer)

 

Returns

the correlation between pid1 and pid2


ncm_fit_covar_fparam_var ()

gdouble
ncm_fit_covar_fparam_var (NcmFit *fit,
                          guint fpi);

Computes the variance of the fitted parameter fpi . This index refers to the list of all FREE parameters set in the MSet.

See also the similar function ncm_fit_covar_var() to which one has to provide the respective model of the parameter.

Parameters

fit

a NcmFit

 

fpi

index of a free parameter

 

Returns

the variance of the fitted parameter fpi


ncm_fit_covar_fparam_sd ()

gdouble
ncm_fit_covar_fparam_sd (NcmFit *fit,
                         guint fpi);

Computes the standard deviation of the fitted parameter fpi . This index refers to the list of all FREE parameters set in the MSet.

See also the similar function ncm_fit_covar_sd() to which one has to provide the respective model of the parameter.

Parameters

fit

a NcmFit

 

fpi

index of a free parameter

 

Returns

the standard deviation of the fitted parameter fpi


ncm_fit_covar_fparam_cov ()

gdouble
ncm_fit_covar_fparam_cov (NcmFit *fit,
                          guint fpi1,
                          guint fpi2);

Computes the covariance between the fitted parameters fpi1 and fpi2 . These indices refers to the list of all FREE parameters set in the MSet.

See also the similar function ncm_fit_covar_cov() to which one has to provide the respective models of the parameters.

Parameters

fit

a NcmFit

 

fpi1

index of a free parameter

 

fpi2

index of a free parameter

 

Returns

the covariance between the fitted parameters pdi1 and fpdi2


ncm_fit_covar_fparam_cor ()

gdouble
ncm_fit_covar_fparam_cor (NcmFit *fit,
                          guint fpi1,
                          guint fpi2);

Computes the correlation between the fitted parameters fpi1 and fpi2 . These indices refers to the list of all FREE parameters set in the MSet.

See also the similar function ncm_fit_covar_cor() to which one has to provide the respective models of the parameters.

Parameters

fit

a NcmFit

 

fpi1

index of a free parameter

 

fpi2

index of a free parameter

 

Returns

the correlation between the fitted parameters pdi1 and fpdi2


ncm_fit_reset ()

void
ncm_fit_reset (NcmFit *fit);

Resets the fit.

Parameters

fit

a NcmFit

 

ncm_fit_run ()

gboolean
ncm_fit_run (NcmFit *fit,
             NcmFitRunMsgs mtype);

Computes the minimization.

Parameters

fit

a NcmFit

 

mtype

a NcmFitRunMsgs

 

Returns

TRUE if the minimization went through.


ncm_fit_run_restart ()

gboolean
ncm_fit_run_restart (NcmFit *fit,
                     NcmFitRunMsgs mtype,
                     const gdouble abstol,
                     const gdouble reltol,
                     NcmMSet *save_mset,
                     const gchar *mset_file);

Re-runs the fit until the difference between fits are less than the required tolerance, i.e., $$ m2lnL_{i-1} - m2lnL_i < \mathrm{abstol} + \mathrm{reltol}\vert m2lnL_{i-1}\vert. $$

Parameters

fit

a NcmFit

 

mtype

a NcmFitRunMsgs

 

abstol

restart absolute tolerance

 

reltol

restart relative tolarence

 

save_mset

the NcmMSet used to save progress.

[nullable]

mset_file

the file name to save progress.

[nullable]

Returns

TRUE if the minimization went through.


ncm_fit_lr_test_range ()

NcmMatrix *
ncm_fit_lr_test_range (NcmFit *fit,
                       NcmModelID mid,
                       guint pid,
                       gdouble start,
                       gdouble stop,
                       guint nsteps);

Computes the likelihood ratio test for the parameter pid of the model mid in the interval [start , stop ] subdivided by nsteps . The function returns a NcmMatrix with the following columns:

  1. Parameter value.

  2. The difference in -2 times the natural logarithm of the likelihood between the full model and the model with the parameter pid fixed to the value in the first column.

  3. The probability density of the difference in -2 times the natural logarithm of the likelihood between the full model and the model with the parameter pid fixed to the value in the first column, assuming a chi-squared distribution with one degree of freedom.

  4. Cumulative probability (two-sides) of the difference (Column 3).

Parameters

fit

a NcmFit

 

mid

a NcmModelID.

 

pid

the parameter id

 

start

starting value

 

stop

ending value

 

nsteps

step size

 

Returns

a NcmMatrix with the results.

[transfer full]


ncm_fit_lr_test ()

gdouble
ncm_fit_lr_test (NcmFit *fit,
                 NcmModelID mid,
                 guint pid,
                 gdouble val,
                 gint dof);

Computes the likelihood ratio test for the parameter pid of the model mid with the value val . The function returns the probability of the null hypothesis assuming a chi-squared distribution with dof degrees of freedom. That is, it computes the left tail of the chi-squared distribution with dof degrees of freedom.

Parameters

fit

a NcmFit.

 

mid

a NcmModelID.

 

pid

the parameter id

 

val

the parameter value

 

dof

degrees of freedom

 

Returns

the probability of the null hypothesis.


ncm_fit_chisq_test ()

gdouble
ncm_fit_chisq_test (NcmFit *fit,
                    size_t bins);

ncm_fit_function_error ()

void
ncm_fit_function_error (NcmFit *fit,
                        NcmMSetFunc *func,
                        gdouble *x,
                        gdouble *f,
                        gdouble *sigma_f);

Propagates the errors in the free parameters to the function func . If no free parameters are set in the NcmMSet object associated to the fit object, the computed error is 0.

Note that the covariance matrix must be calculated before calling this function. Otherwise, it will raise an error.

Parameters

fit

a NcmFit

 

func

a NcmMSetFunc

 

x

the argument for the function

 

f

the function value.

[out]

sigma_f

the error in the function value.

[out]

Types and Values

NCM_TYPE_FIT

#define NCM_TYPE_FIT (ncm_fit_get_type ())

enum NcmFitType

Defines the subclasse of NcmFit to be used.

Members

NCM_FIT_TYPE_GSL_LS

GSL Least Squares

 

NCM_FIT_TYPE_GSL_MM

GSL Multidimensional Minimization

 

NCM_FIT_TYPE_GSL_MMS

GSL Multidimensional Minimization (simplex)

 

NCM_FIT_TYPE_LEVMAR

Levmar Least Squares Library

 

NCM_FIT_TYPE_NLOPT

Non Linear Optimization (NLOpt)

 

enum NcmFitGradType

Defines the type of gradient calculation.

Members

NCM_FIT_GRAD_NUMDIFF_FORWARD

Numerical gradient (forward)

 

NCM_FIT_GRAD_NUMDIFF_CENTRAL

Numerical gradient (central)

 

NCM_FIT_GRAD_NUMDIFF_ACCURATE

Numerical gradient (accurate)

 

enum NcmFitRunMsgs

Defines the type of messages to be printed during the fit.

Members

NCM_FIT_RUN_MSGS_NONE

Messages disabled

 

NCM_FIT_RUN_MSGS_SIMPLE

Messages enabled

 

NCM_FIT_RUN_MSGS_FULL

Messages enabled (full)

 

struct NcmFitClass

struct NcmFitClass {
};

NCM_FIT_DEFAULT_M2LNL_RELTOL

#define NCM_FIT_DEFAULT_M2LNL_RELTOL (1e-8)

NCM_FIT_DEFAULT_M2LNL_ABSTOL

#define NCM_FIT_DEFAULT_M2LNL_ABSTOL (0.0)

NCM_FIT_DEFAULT_PARAMS_RELTOL

#define NCM_FIT_DEFAULT_PARAMS_RELTOL (1e-5)

NCM_FIT_DEFAULT_MAXITER

#define NCM_FIT_DEFAULT_MAXITER 100000

NcmFit

typedef struct _NcmFit NcmFit;

Property Details

The “equality-constraints” property

  “equality-constraints”     NcmObjArray *

Equality constraints array.

Owner: NcmFit

Flags: Read / Write


The “equality-constraints-tot” property

  “equality-constraints-tot” NcmVector *

Equality constraints tolerance.

Owner: NcmFit

Flags: Read / Write


The “grad-type” property

  “grad-type”                NcmFitGradType

Differentiation method.

Owner: NcmFit

Flags: Read / Write / Construct

Default value: NCM_FIT_GRAD_NUMDIFF_FORWARD


The “inequality-constraints” property

  “inequality-constraints”   NcmObjArray *

Inequality constraints array.

Owner: NcmFit

Flags: Read / Write


The “inequality-constraints-tot” property

  “inequality-constraints-tot” NcmVector *

Inequality constraints tolerance.

Owner: NcmFit

Flags: Read / Write


The “likelihood” property

  “likelihood”               NcmLikelihood *

Likelihood object.

Owner: NcmFit

Flags: Read / Write / Construct Only


The “m2lnL-abstol” property

  “m2lnL-abstol”             double

Absolute tolarence in m2lnL.

Owner: NcmFit

Flags: Read / Write / Construct

Allowed values: >= 0

Default value: 0


The “m2lnL-reltol” property

  “m2lnL-reltol”             double

Relative tolarence in m2lnL.

Owner: NcmFit

Flags: Read / Write / Construct

Allowed values: >= 0

Default value: 1e-08


The “maxiter” property

  “maxiter”                  guint

Maximum number of interations.

Owner: NcmFit

Flags: Read / Write / Construct

Default value: 100000


The “mset” property

  “mset”                     NcmMSet *

Model set object.

Owner: NcmFit

Flags: Read / Write / Construct Only


The “params-reltol” property

  “params-reltol”            double

Relative tolarence in fitted parameters.

Owner: NcmFit

Flags: Read / Write / Construct

Allowed values: >= 0

Default value: 1e-05


The “state” property

  “state”                    NcmFitState *

Fit state object.

Owner: NcmFit

Flags: Read / Write / Construct Only


The “sub-fit” property

  “sub-fit”                  NcmFit *

Subsidiary fit.

Owner: NcmFit

Flags: Read / Write