#include "LinFitAlg.h"
|
void | LinFit (std::vector< float > &x, std::vector< float > &y, std::vector< float > &ey2, float &Intercept, float &Slope, float &InterceptError, float &SlopeError, float &ChiDOF) const |
|
Definition at line 17 of file LinFitAlg.h.
void trkf::LinFitAlg::LinFit |
( |
std::vector< float > & |
x, |
|
|
std::vector< float > & |
y, |
|
|
std::vector< float > & |
ey2, |
|
|
float & |
Intercept, |
|
|
float & |
Slope, |
|
|
float & |
InterceptError, |
|
|
float & |
SlopeError, |
|
|
float & |
ChiDOF |
|
) |
| const |
Definition at line 16 of file LinFitAlg.cxx.
References sum, and weight.
30 if (y.size() < 2)
return;
31 if (x.size() < y.size() || ey2.size() < y.size())
return;
42 for (ii = 0; ii < y.size(); ++ii) {
43 weight = 1. / ey2[ii];
45 sumx += weight * x[ii];
46 sumy += weight * y[ii];
47 sumx2 += weight * x[ii] * x[ii];
48 sumxy += weight * x[ii] * y[ii];
49 sumy2 += weight * y[ii] * y[ii];
52 double delta = sum * sumx2 - sumx * sumx;
53 if (delta == 0.)
return;
54 double A = (sumx2 * sumy - sumx * sumxy) / delta;
55 double B = (sumxy * sum - sumx * sumy) / delta;
62 double ndof = x.size() - 2;
64 (sumy2 + A * A * sum + B * B * sumx2 - 2 * (A * sumy + B * sumxy - A * B * sumx)) / ndof;
66 InterceptError = sqrt(varnce * sumx2 / delta);
67 SlopeError = sqrt(varnce * sum / delta);
75 for (ii = 0; ii < y.size(); ++ii) {
76 arg = y[ii] - A - B * x[ii];
77 sum += arg * arg / ey2[ii];
The documentation for this class was generated from the following files: