Class fit_fix_pars (o2scl)

O2scl : Class List

template<class bool_vec_t, class func_t = gen_fit_funct<>, class vec_t = boost::numeric::ublas::vector<double>, class mat_t = boost::numeric::ublas::matrix<double>>
class fit_fix_pars : public o2scl::fit_base<gen_fit_funct<>, boost::numeric::ublas::vector<double>, boost::numeric::ublas::matrix<double>>, public o2scl::gen_fit_funct<boost::numeric::ublas::vector<double>, boost::numeric::ublas::matrix<double>>

Multidimensional fitting class fixing some parameters and varying others.

The number of trials used in the fit can be specified in the data member of the parent class fit_base::ntrial associated with the fit_fix_pars object. Similarly for the verbosity parameter in fit_base::verbose, the absolute tolerance in fit_base::tol_abs, and the relative tolerance in fit_base::tol_abs. These values are copied to the minimizer used by fit_fix_pars::mmin() during each call. After the minimizer is called, the value of fit_base::ntrial associated with the fit_fix_pars object is filled with the last number of trials required for the last minimization.

Default template arguments

  • func_t - gen_fit_funct<>

  • vec_t - boost::numeric::ublas::vector <double >

  • mat_t - boost::numeric::ublas::matrix <double >

Reimplementation of \ref gen_fit_funct

vec_t u_par

Temporary vector to store full parameter list of size u_np.

vec_t u_par_new

Vector for smaller parameter list of size u_np_new.

mat_t J

Jacobian in the user space of size (nd,u_np)

base_fit_t *fitp

The fitter.

func_t *funcp

The user-specified function.

size_t u_np

The user-specified number of variables.

size_t u_np_new

The new number of variables.

bool_vec_t *fix_par

Specify which parameters to fix (vector of size u_np)

vec_t *x_par

The user-specified initial vector of size u_np.

inline virtual size_t get_ndata()

The function to return the number of data points.

inline virtual void operator()(size_t np_new, const vec_t &par_new, size_t nd, vec_t &f)

The function computing deviations.

This function operates in the smaller space of size np_new.

inline virtual void jac(size_t np_new, vec_t &par_new, size_t nd, vec_t &f, mat_t &J_new)

The function computing the Jacobian.

fit_fix_pars(const fit_fix_pars&)
fit_fix_pars &operator=(const fit_fix_pars&)

Public Types

typedef fit_base<fit_fix_pars<bool_vec_t, func_t, vec_t, mat_t>, vec_t, mat_t> base_fit_t

The generic fitter type.

typedef fit_nonlin<fit_fix_pars<bool_vec_t, func_t, vec_t, mat_t>, vec_t, mat_t> def_fit_t

The default fitter type.

Public Functions

inline fit_fix_pars()

Specify the member function pointer.

inline virtual ~fit_fix_pars()
inline virtual int fit(size_t np, vec_t &par, mat_t &covar, double &chi2, func_t &fitfun)

Fit the data specified in (xdat,ydat) to the function fitfun with the parameters in par.

The covariance matrix for the parameters is returned in covar and the value of \( \chi^2 \) is returned in chi2.

inline virtual int fit_fix(size_t np, vec_t &par, mat_t &covar, double &chi2, func_t &fitfun, bool_vec_t &fix)

Fit function func while fixing some parameters as specified in fix.

Note

When some parameters are fixed, each fixed parameter leads to a row and column in the covariance matrix which is unused by this function. If there are npar2<npar unfixed parameters, then only the first npar2 rows and columns of covar are filled.

inline int set_fit(base_fit_t &fitter)

Change the base fitter.

Public Members

bool expand_covar

If true, expand the covariance matrix to the larger space by filling with the identity matrix (default false)

If this varable is false (the default), then the covariance matrix is computed in the smaller space which enumerates only the parameters which are not fixed. If this variable is true, then the covariance matrix must be a full np by np matrix (where np is the argument to fit() or fit_fix() ) and rows and columns which correspond with parameters which are fixed are replaced by elements from the identity matrix.

The optimal parameters and \( \chi^2 \) reported by the fit are unchanged.

def_fit_t def_fit

The default base fitter.