Main Page
Namespaces
Classes
Package Documentation
CommonTools
Statistics
src
LinearFit.cc
Go to the documentation of this file.
1
#include "
CommonTools/Statistics/interface/LinearFit.h
"
2
3
void
LinearFit::fit
(
const
std::vector<float> &
x
,
const
std::vector<float> &
y
,
4
int
ndat,
const
std::vector<float> & sigy,
5
float
&
slope
,
float
& intercept,
6
float
& covss,
float
& covii,
float
& covsi)
const
7
{
8
9
float
g1
= 0,
g2
= 0;
10
float
s11 = 0, s12 = 0, s22 = 0;
11
for
(
int
i
= 0;
i
!= ndat;
i
++) {
12
float
sy2 = sigy[
i
] * sigy[
i
];
13
g1 += y[
i
] / sy2;
14
g2
+= x[
i
]*y[
i
] / sy2;
15
s11 += 1. / sy2;
16
s12 += x[
i
] / sy2;
17
s22 += x[
i
]*x[
i
] / sy2;
18
}
19
20
float
d
= s11*s22 - s12*s12;
21
intercept = (g1*s22 -
g2
*s12) / d;
22
slope = (
g2
*s11 - g1*s12) / d;
23
24
covii = s22 /
d
;
25
covss = s11 /
d
;
26
covsi = -s12 /
d
;
27
28
}
mps_fire.i
i
Definition:
mps_fire.py:156
diffTwoXMLs.g1
g1
Definition:
diffTwoXMLs.py:51
LinearFit::fit
void fit(const std::vector< float > &x, const std::vector< float > &y, int ndat, const std::vector< float > &sigy, float &slope, float &intercept, float &covss, float &covii, float &covsi) const
Definition:
LinearFit.cc:3
LinearFit.h
slope
static const double slope[3]
Definition:
CastorTimeSlew.cc:6
vertices_cff.x
x
Definition:
vertices_cff.py:29
edmIntegrityCheck.d
d
Definition:
edmIntegrityCheck.py:65
diffTwoXMLs.g2
g2
Definition:
diffTwoXMLs.py:70
detailsBasic3DVector::y
float float y
Definition:
extBasic3DVector.h:15
Generated for CMSSW Reference Manual by
1.8.11