mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2025-07-03 13:27:06 +01:00
empirical p-value function
This commit is contained in:
@ -35,6 +35,7 @@ int main(void)
|
|||||||
|
|
||||||
cout << static_cast<int>(s) << " sigma(s) interval= [";
|
cout << static_cast<int>(s) << " sigma(s) interval= [";
|
||||||
cout << ci.first << ", " << ci.second << "]" << endl;
|
cout << ci.first << ", " << ci.second << "]" << endl;
|
||||||
|
cout << "P(X > " << s << ") = " << h.pValue(s) + 1. - h.pValue(-s) << endl;
|
||||||
}
|
}
|
||||||
p << PlotHistogram(h);
|
p << PlotHistogram(h);
|
||||||
p << PlotFunction(compile("return exp(-x_0^2/2)/sqrt(2*pi);", 1), -5., 5.);
|
p << PlotFunction(compile("return exp(-x_0^2/2)/sqrt(2*pi);", 1), -5., 5.);
|
||||||
|
@ -162,6 +162,20 @@ double Histogram::operator()(const double x) const
|
|||||||
return (*this)[static_cast<Index>(i)];
|
return (*this)[static_cast<Index>(i)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// p-value P(x > x0) ///////////////////////////////////////////////////////////
|
||||||
|
double Histogram::pValue(const double x0) const
|
||||||
|
{
|
||||||
|
Index n = data_.size();
|
||||||
|
double count = 0.;
|
||||||
|
|
||||||
|
FOR_STAT_ARRAY(data_, s)
|
||||||
|
{
|
||||||
|
count += (data_[s] > x0) ? 1. : 0.;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count/n;
|
||||||
|
}
|
||||||
|
|
||||||
// percentiles & confidence interval ///////////////////////////////////////////
|
// percentiles & confidence interval ///////////////////////////////////////////
|
||||||
double Histogram::percentile(const double p) const
|
double Histogram::percentile(const double p) const
|
||||||
{
|
{
|
||||||
|
@ -54,6 +54,8 @@ public:
|
|||||||
double getX(const Index i) const;
|
double getX(const Index i) const;
|
||||||
double operator[](const Index i) const;
|
double operator[](const Index i) const;
|
||||||
double operator()(const double x) const;
|
double operator()(const double x) const;
|
||||||
|
// p-value P(x > x0)
|
||||||
|
double pValue(const double x0) const;
|
||||||
// percentiles & confidence interval
|
// percentiles & confidence interval
|
||||||
double percentile(const double p) const;
|
double percentile(const double p) const;
|
||||||
double median(void) const;
|
double median(void) const;
|
||||||
|
Reference in New Issue
Block a user