Class fit_min (o2scl)

O2scl : Class List

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

Non-linear least-squares fitting class with generic minimizer.

This minimizes a generic fitting function using any o2scl::mmin_base object, and then uses the GSL routines to calculate the uncertainties in the parameters and the covariance matrix.

This can be useful for fitting problems which might be better handled by more complex minimizers than those that are used in o2scl::fit_nonlin. For problems with many local minima near the global minimum, using a o2scl::anneal_base object with this class can sometimes produce better results than o2scl::fit_nonlin.

Default template arguments

  • func_t - gen_fit_funct<>

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

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

Public Functions

inline fit_min()
inline virtual ~fit_min()
inline virtual int fit(size_t npar, 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 int set_mmin(mmin_base<multi_funct> &mm)

Set the mmin object to use (default is of type o2scl::mmin_simp2)

inline virtual const char *type()

Return string denoting type (“fit_min”)

Public Members

mmin_simp2<multi_funct> def_mmin

The default minimizer.

Protected Functions

inline double min_func(size_t np, const vec_t &xp)

The function to minimize, \( \chi^2 \).

Protected Attributes

vec_t fval

Storage for the function values.

func_t *func

Pointer to the user-specified fitting function.

mmin_base<multi_funct> *mmp

The minimizer.

bool min_set

True if the minimizer has been set by the user.