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
,
4
const
std::vector<float>&
y
,
5
int
ndat,
6
const
std::vector<float>& sigy,
7
float
&
slope
,
8
float
& intercept,
9
float
& covss,
10
float
& covii,
11
float
& covsi)
const
{
12
float
g1
= 0,
g2
= 0;
13
float
s11 = 0, s12 = 0, s22 = 0;
14
for
(
int
i
= 0;
i
!= ndat;
i
++) {
15
float
sy2 = sigy[
i
] * sigy[
i
];
16
g1
+=
y
[
i
] / sy2;
17
g2
+=
x
[
i
] *
y
[
i
] / sy2;
18
s11 += 1. / sy2;
19
s12 +=
x
[
i
] / sy2;
20
s22 +=
x
[
i
] *
x
[
i
] / sy2;
21
}
22
23
float
d
= s11 * s22 - s12 * s12;
24
intercept = (
g1
* s22 -
g2
* s12) /
d
;
25
slope
= (
g2
* s11 -
g1
* s12) /
d
;
26
27
covii = s22 /
d
;
28
covss = s11 /
d
;
29
covsi = -s12 /
d
;
30
}
DDAxes::y
mps_fire.i
i
Definition:
mps_fire.py:428
diffTwoXMLs.g1
g1
Definition:
diffTwoXMLs.py:52
LinearFit.h
DDAxes::x
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
diffTwoXMLs.g2
g2
Definition:
diffTwoXMLs.py:71
genVertex_cff.x
x
Definition:
genVertex_cff.py:13
detailsBasic3DVector::y
float float y
Definition:
extBasic3DVector.h:14
ztail.d
d
Definition:
ztail.py:151
slope
static const double slope[3]
Definition:
CastorTimeSlew.cc:6
Generated for CMSSW Reference Manual by
1.8.16