#ifndef ROOT_Fit_FitResult
#define ROOT_Fit_FitResult
#ifndef ROOT_Fit_IFunctionfwd
#include "Math/IFunctionfwd.h"
#endif
#ifndef ROOT_Fit_IParamFunctionfwd
#include "Math/IParamFunctionfwd.h"
#endif
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
namespace ROOT {
namespace Math {
class Minimizer;
}
namespace Fit {
class FitConfig;
class BinData;
class FitResult {
public:
typedef ROOT::Math::IParamMultiFunction IModelFunction;
FitResult ();
FitResult(ROOT::Math::Minimizer & min, const FitConfig & fconfig, const IModelFunction * f, bool isValid, unsigned int sizeOfData = 0, bool binFit = true, const ROOT::Math::IMultiGenFunction * chi2func = 0, bool minosErr = false, unsigned int ncalls = 0);
FitResult(const FitResult &);
FitResult & operator = (const FitResult & rhs);
~FitResult ();
public:
const std::string & MinimizerType() const { return fMinimType; }
bool IsValid() const { return fValid; }
bool IsEmpty() const { return (fParams.size() == 0); }
double MinFcnValue() const { return fVal; }
unsigned int NCalls() const { return fNCalls; }
double Edm() const { return fEdm; }
unsigned int NTotalParameters() const { return fParams.size(); }
unsigned int NFreeParameters() const { return fNFree; }
int Status() const { return fStatus; }
const IModelFunction * FittedFunction() const { return fFitFunc; }
double Chi2() const { return fChi2; }
unsigned int Ndf() const { return fNdf; }
double Prob() const;
const std::vector<double> & Errors() const { return fErrors; }
const std::vector<double> & Parameters() const { return fParams; }
double Value(unsigned int i) const { return fParams[i]; }
double Error(unsigned int i) const {
return (i < fErrors.size() ) ? fErrors[i] : 0;
}
double LowerError(unsigned int i) const {
return (i < fMinosErrors.size() ) ? fMinosErrors[i].first : fErrors[i];
}
double UpperError(unsigned int i) const {
return (i < fMinosErrors.size() ) ? fMinosErrors[i].second : fErrors[i];
}
double GlobalCC(unsigned int i) const {
return (i < fGlobalCC.size() ) ? fGlobalCC[i] : -1;
}
double CovMatrix (unsigned int i, unsigned int j) const {
if ( i >= fErrors.size() || j >= fErrors.size() ) return 0;
if (fCovMatrix.size() == 0) return 0;
if ( j < i )
return fCovMatrix[j + i* (i+1) / 2];
else
return fCovMatrix[i + j* (j+1) / 2];
}
double Correlation(unsigned int i, unsigned int j ) const {
if ( i >= fErrors.size() || j >= fErrors.size() ) return 0;
if (fCovMatrix.size() == 0) return 0;
double tmp = CovMatrix(i,i)*CovMatrix(j,j);
return ( tmp > 0) ? CovMatrix(i,j)/ std::sqrt(tmp) : 0;
}
template<class Matrix>
void GetCovarianceMatrix(Matrix & mat) {
int npar = fErrors.size();
assert(fCovMatrix.size() == npar*(npar+1)/2);
for (int i = 0; i< npar; ++i) {
for (int j = 0; j<=i; ++i) {
mat(i,j) = fCovMatrix[j + i*(i+1)/2 ];
}
}
}
template<class Matrix>
void GetCorrelationMatrix(Matrix & mat) {
int npar = fErrors.size();
assert(fCovMatrix.size() == npar*(npar+1)/2);
for (int i = 0; i< npar; ++i) {
for (int j = 0; j<=i; ++i) {
double tmp = fCovMatrix[i * (i +3)/2 ] * fCovMatrix[ j * (j+3)/2 ];
if (tmp < 0)
mat(i,j) = 0;
else
mat(i,j) = fCovMatrix[j + i*(i+1)/2 ] / std::sqrt(tmp);
}
}
}
void GetConfidenceIntervals(unsigned int n, unsigned int stride1, unsigned int stride2, const double * x, double * ci, double cl=0.95 ) const;
void GetConfidenceIntervals(const BinData & data, double * ci, double cl=0.95 ) const;
int Index(const std::string & name) const;
void NormalizeErrors();
bool NormalizedErrors() { return fNormalized; }
void Print(std::ostream & os, bool covmat = false) const;
void PrintCovMatrix(std::ostream & os) const;
bool IsParameterBound(unsigned int ipar) const;
bool IsParameterFixed(unsigned int ipar) const;
std::string GetParameterName(unsigned int ipar) const;
protected:
private:
IModelFunction * ModelFunction() { return fFitFunc; }
void SetModelFunction(IModelFunction * func) { fFitFunc = func; }
friend class Fitter;
bool fValid;
bool fNormalized;
unsigned int fNFree;
unsigned int fNdf;
unsigned int fNCalls;
int fStatus;
double fVal;
double fEdm;
double fChi2;
IModelFunction * fFitFunc;
std::vector<unsigned int> fFixedParams;
std::vector<unsigned int> fBoundParams;
std::vector<double> fParams;
std::vector<double> fErrors;
std::vector<double> fCovMatrix;
std::vector<double> fGlobalCC;
std::vector<std::pair<double,double> > fMinosErrors;
std::string fMinimType;
std::vector<std::string> fParNames;
};
}
}
#endif /* ROOT_Fit_FitResult */
Last change: Fri Dec 12 12:11:38 2008
Last generated: 2008-12-12 12:11
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.