1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2025-04-10 19:20:44 +01:00

method to get fit p-value from fit interface

This commit is contained in:
Antonin Portelli 2015-11-25 18:29:31 +00:00
parent 25698fc6b2
commit e950e18639
5 changed files with 19 additions and 2 deletions

View File

@ -39,8 +39,9 @@ int main(void)
data.fitAllPoints(); data.fitAllPoints();
p = data.fit(minimizer, init, f); p = data.fit(minimizer, init, f);
cout << "a= " << p(0) << " b= " << p(1) cout << "a= " << p(0) << " b= " << p(1);
<< " chi^2/ndof= " << p.getChi2PerDof() << endl; cout << " chi^2/ndof= " << p.getChi2PerDof();
cout << " p-value= " << p.getPValue() <<endl;
// plot result // plot result
Plot plot; Plot plot;

View File

@ -18,10 +18,12 @@
*/ */
#include <LatAnalyze/XYSampleData.hpp> #include <LatAnalyze/XYSampleData.hpp>
#include <LatAnalyze/Math.hpp>
#include <LatAnalyze/includes.hpp> #include <LatAnalyze/includes.hpp>
using namespace std; using namespace std;
using namespace Latan; using namespace Latan;
using namespace Math;
/****************************************************************************** /******************************************************************************
* SampleFitResult implementation * * SampleFitResult implementation *
@ -51,6 +53,11 @@ double SampleFitResult::getNDof(void) const
return static_cast<double>(nDof_); return static_cast<double>(nDof_);
} }
double SampleFitResult::getPValue(const Index s) const
{
return chi2PValue(getChi2(s), getNDof());
}
const DoubleFunction & SampleFitResult::getModel(const Index s, const DoubleFunction & SampleFitResult::getModel(const Index s,
const Index j) const const Index j) const
{ {

View File

@ -47,6 +47,7 @@ public:
double getChi2PerDof(const Index s = central) const; double getChi2PerDof(const Index s = central) const;
DSample getChi2PerDof(const PlaceHolder ph) const; DSample getChi2PerDof(const PlaceHolder ph) const;
double getNDof(void) const; double getNDof(void) const;
double getPValue(const Index s = central) const;
const DoubleFunction & getModel(const Index s = central, const DoubleFunction & getModel(const Index s = central,
const Index j = 0) const; const Index j = 0) const;
const DoubleFunctionSample & getModel(const PlaceHolder ph, const DoubleFunctionSample & getModel(const PlaceHolder ph,

View File

@ -19,9 +19,11 @@
#include <LatAnalyze/XYStatData.hpp> #include <LatAnalyze/XYStatData.hpp>
#include <LatAnalyze/includes.hpp> #include <LatAnalyze/includes.hpp>
#include <LatAnalyze/Math.hpp>
using namespace std; using namespace std;
using namespace Latan; using namespace Latan;
using namespace Math;
/****************************************************************************** /******************************************************************************
* FitResult implementation * * FitResult implementation *
@ -42,6 +44,11 @@ double FitResult::getNDof(void) const
return static_cast<double>(nDof_); return static_cast<double>(nDof_);
} }
double FitResult::getPValue(void) const
{
return chi2PValue(getChi2(), getNDof());;
}
const DoubleFunction & FitResult::getModel(const Index j) const const DoubleFunction & FitResult::getModel(const Index j) const
{ {
return model_[static_cast<unsigned int>(j)]; return model_[static_cast<unsigned int>(j)];

View File

@ -48,6 +48,7 @@ public:
double getChi2(void) const; double getChi2(void) const;
double getChi2PerDof(void) const; double getChi2PerDof(void) const;
double getNDof(void) const; double getNDof(void) const;
double getPValue(void) const;
const DoubleFunction & getModel(const Index j = 0) const; const DoubleFunction & getModel(const Index j = 0) const;
private: private:
double chi2_{0.0}; double chi2_{0.0};