|
ATLAS Offline Software
|
Go to the documentation of this file.
6 #include "GaudiKernel/MsgStream.h"
8 #include "gsl/gsl_statistics.h"
9 #include "gsl/gsl_fit.h"
17 std::ostringstream oss;
18 oss <<
"Mean=" <<
fMean
21 <<
", Chi2=" <<
fChi2;
28 gsl_fit_linear_est(fX, fIntercept, fSlope, fCov[0][0], fCov[0][1], fCov[1][1], &fY, &fYerr);
33 std::ostringstream oss;
34 oss <<
"Y=" << fIntercept <<
"+X*" << fSlope
36 <<
", Cov=[[" << fCov[0][0] <<
"," << fCov[0][1] <<
"],["
37 << fCov[1][0] <<
"," << fCov[1][1] <<
"]]"
38 <<
", Chi2=" << fChi2;
46 double *
y =
new double[
points.size()];
47 double *
w =
new double[
points.size()];
48 for (
unsigned iPt = 0; iPt <
points.size(); iPt++)
51 if (!
points[iPt]->bExclude)
58 if (
stats.n == 0)
goto done;
61 if (
stats.n == 1)
goto done;
65 double fDiff =
y[
i] -
stats.fMean;
66 stats.fChi2 +=
w[
i] * fDiff * fDiff;
76 double *
y =
new double[
points.size()];
77 double *
w =
new double[
points.size()];
81 for (
unsigned iPt = 0; iPt <
points.size(); iPt++)
84 if (!
points[iPt]->bExclude)
92 if (
stats.n == 0)
goto done;
94 if (
stats.n == 1)
goto done;
97 int i = 0, iPtMax = 0;
98 for (
unsigned iPt = 0; iPt <
points.size(); iPt++)
100 if (!
points[iPt]->bExclude)
102 double fDiff =
y[
i] -
stats.fMean;
103 points[iPt]->fChi2 =
w[
i] * fDiff * fDiff;
105 if (fMaxChi2 <
points[iPt]->fChi2)
107 fMaxChi2 =
points[iPt]->fChi2;
115 <<
", chi2=" <<
points[iPt]->fChi2
123 if (fMaxChi2 < fExclChi2 ||
stats.n <= 2)
125 points[iPtMax]->bExclude =
true;
135 double *
x =
new double[
points.size()];
136 double *
y =
new double[
points.size()];
137 double *
w =
new double[
points.size()];
141 for (
unsigned iPt = 0; iPt <
points.size(); iPt++)
143 if (!
points[iPt]->bExclude)
151 if (
stats.n < 2)
goto done;
153 gsl_fit_wlinear(
x, 1,
164 double fY, fYerr, fMaxChi2 = 0;
165 int i = 0, iPtMax = 0;
166 for (
unsigned iPt = 0; iPt <
points.size(); iPt++)
168 if (!
points[iPt]->bExclude)
171 double fDiff =
y[
i] - fY;
172 points[iPt]->fChi2 =
w[
i] * fDiff * fDiff;
173 if (fMaxChi2 <
points[iPt]->fChi2)
175 fMaxChi2 =
points[iPt]->fChi2;
185 <<
", chi2=" <<
points[iPt]->fChi2
191 if (fMaxChi2 < fExclChi2 ||
stats.n <= 2)
193 points[iPtMax]->bExclude =
true;
static void fitLine(PointArray &points, double fExclChi2, bool bDump, LinStats &stats)
Fit a straight line through the given points.
singleton-like access to IMessageSvc via open function and helper
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
IMessageSvc * getMessageSvc(bool quiet=false)
void eval(double fX, double &fY, double &fYerr) const
Evaluate a point along the fitted line.
static void fitPoint(PointArray &points, double fExclChi2, bool bDump, SimpleStats &stats)
Estimate a new point from the given points.
std::vector< Point * > PointArray
A vector of points.
std::string toString() const
Get a string representation of the fit parameters.
static void SimpleStatistics(const PointArray &points, SimpleStats &stats)
Calculate simple statistics for the Y values of a set of points.
std::string toString() const