Parent Directory
|
Revision Log
import changes from math development branches for subdirectory math. List of changes in detail:
mathcore:
---------
MinimizerOptions:
new class for storing Minimizer option, with static default values that can be
changed by the user
FitConfig:
- use default values from MinimizerOption class
- rename method to create parameter settings from a function
FitUtil.cxx:
improve the derivative calculations used in the effective chi2 and in Fumili and
fix a bug for evaluation of likelihood or chi2 terms.
In EvaluatePdf() work and return the log of the pdf.
FitResult:
- improve the class by adding extra information like, num. of free parameters,
minimizer status, global correlation coefficients, information about fixed
and bound parameters.
- add method for getting fit confidence intervals
- improve print method
DataRange:
add method SetRange to distinguish from AddRange. SetRange deletes the existing
ranges.
ParamsSettings: make few methods const
FCN functions (Chi2FCN, LogLikelihoodFCN, etc..)
move some common methods and data members in base class (FitMethodFunction)
RootFinder: add template Solve() for any callable function.
mathmore:
--------
minimizer classes: fill status information
GSLNLSMinimizer: return error and covariance matrix
minuit2:
-------
Minuit2Minimizer: fill status information
DavidonErrorUpdator: check that delgam or gvg are not zero ( can happen when dg = 0)
FumiliFCNAdapter: work on the log of pdf
minuit:
-------
TLinearMinimizer: add support for robust fitting
TMinuitMinimizer: fill status information and fix a bug in filling the correlation matrix.
fumili:
------
add TFumiliMinimizer:
wrapper class for TFumili using Minimizer interface
// @(#)root/mathcore:$Id$
// Author: L. Moneta Tue Sep 5 09:13:32 2006
/**********************************************************************
* *
* Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT *
* *
* *
**********************************************************************/
// Header file for class Chi2FCN
#ifndef ROOT_Fit_Chi2FCN
#define ROOT_Fit_Chi2FCN
#ifndef ROOT_Math_FitMethodunction
#include "Math/FitMethodFunction.h"
#endif
#ifndef ROOT_Math_IParamFunction
#include "Math/IParamFunction.h"
#endif
#ifndef ROOT_Fit_BinData
#include "Fit/BinData.h"
#endif
#ifndef ROOT_Fit_FitUtil
#include "Fit/FitUtil.h"
#endif
//#define ROOT_FIT_PARALLEL
#ifdef ROOT_FIT_PARALLEL
#ifndef ROOT_Fit_FitUtilParallel
#include "Fit/FitUtilParallel.h"
#endif
#endif
/**
@defgroup FitMethodFunc Fit Method Classes
Classes describing Fit Method functions
@ingroup Fit
*/
namespace ROOT {
namespace Fit {
template<class FunType>
struct ModelFunctionTrait {
typedef ::ROOT::Math::IParamMultiFunction ModelFunc;
};
template<>
struct ModelFunctionTrait<ROOT::Math::IMultiGradFunction> {
typedef ::ROOT::Math::IParamMultiGradFunction ModelFunc;
};
//___________________________________________________________________________________
/**
Chi2FCN class for binnned fits using the least square methods
@ingroup FitMethodFunc
*/
template<class FunType>
class Chi2FCN : public ::ROOT::Math::BasicFitMethodFunction<FunType> {
public:
typedef ::ROOT::Math::BasicFitMethodFunction<FunType> BaseObjFunction;
typedef typename BaseObjFunction::BaseFunction BaseFunction;
typedef typename ModelFunctionTrait<FunType>::ModelFunc IModelFunction;
typedef typename BaseObjFunction::Type Type;
/**
Constructor from data set (binned ) and model function
*/
Chi2FCN (const BinData & data, IModelFunction & func) :
BaseObjFunction(func.NPar(), data.Size() ),
fData(data),
fFunc(func),
fNEffPoints(0),
fGrad ( std::vector<double> ( func.NPar() ) )
{ }
/**
Destructor (no operations)
*/
virtual ~Chi2FCN () {}
#ifdef LATER
private:
// usually copying is non trivial, so we make this unaccessible
/**
Copy constructor
*/
Chi2FCN(const Chi2FCN &);
/**
Assignment operator
*/
Chi2FCN & operator = (const Chi2FCN & rhs);
#endif
public:
virtual BaseFunction * Clone() const {
// clone the function
Chi2FCN * fcn = new Chi2FCN(fData,fFunc);
return fcn;
}
using BaseObjFunction::operator();
// effective points used in the fit (exclude the rejected one)
virtual unsigned int NFitPoints() const { return fNEffPoints; }
/// i-th chi-square residual
virtual double DataElement(const double * x, unsigned int i, double * g) const {
return FitUtil::EvaluateChi2Residual(fFunc, fData, x, i, g);
}
// need to be virtual to be instantited
virtual void Gradient(const double *x, double *g) const {
// evaluate the chi2 gradient
FitUtil::EvaluateChi2Gradient(fFunc, fData, x, g, fNEffPoints);
}
/// get type of fit method function
virtual typename BaseObjFunction::Type GetType() const { return BaseObjFunction::kLeastSquare; }
/// access to const reference to the data
virtual const BinData & Data() const { return fData; }
/// access to const reference to the model function
virtual const IModelFunction & ModelFunction() const { return fFunc; }
protected:
/// set number of fit points (need to be called in const methods, make it const)
virtual void SetNFitPoints(unsigned int n) const { fNEffPoints = n; }
private:
/**
Evaluation of the function (required by interface)
*/
virtual double DoEval (const double * x) const {
this->UpdateNCalls();
#ifdef ROOT_FIT_PARALLEL
return FitUtilParallel::EvaluateChi2(fFunc, fData, x, fNEffPoints);
#else
if (!fData.HaveCoordErrors() )
return FitUtil::EvaluateChi2(fFunc, fData, x, fNEffPoints);
else
return FitUtil::EvaluateChi2Effective(fFunc, fData, x, fNEffPoints);
#endif
}
// for derivatives
virtual double DoDerivative(const double * x, unsigned int icoord ) const {
Gradient(x, &fGrad[0]);
return fGrad[icoord];
}
const BinData & fData;
mutable IModelFunction & fFunc;
mutable unsigned int fNEffPoints; // number of effective points used in the fit
mutable std::vector<double> fGrad; // for derivatives
};
} // end namespace Fit
} // end namespace ROOT
#endif /* ROOT_Fit_Chi2FCN */
| Subversion Admin | ViewVC Help |
| Powered by ViewVC 1.0.9 |