ICRC2019/Statistics.hh
Go to the documentation of this file.
1 void poisson_uncertainty(double x, double& plow, double& pup)
2 {
3 
4  plow = x - TMath::ChisquareQuantile(0.16, 2 * x) / 2;
5  pup = TMath::ChisquareQuantile(0.84, 2 * (x + 1)) / 2 - x;
6 
7 
8 }
9 
10 TMatrixD jacobian(TVectorD(*f)(TVectorD, string),
11  TVectorD x, TVectorD dx,
12  string stringtype)
13 {
14 
15  int nx = x.GetNoElements();
16  TVectorD y = f(x, stringtype);
17  int ny = y.GetNoElements();
18 
19  TMatrixD jacobi(ny, nx);
20  jacobi.Zero();
21 
22  TVectorD e(nx);
23  e.Zero();
24 
25  for (int ix = 0; ix < nx; ++ix) {
26  e.Zero();
27  e[ix] = 1 * dx[ix];
28 
29  TVectorD t1 = f(x + e, stringtype);
30  TVectorD t2 = f(x, stringtype);
31  TVectorD tmp = (f(x + e, stringtype) - f(x, stringtype));
32 
33  TVectorD der = tmp;
34 
35  for (int iy = 0; iy < ny; ++iy) {
36  jacobi[iy][ix] = der[iy] / dx[ix]; // if ny > 1 else der
37  }
38 
39 
40  }
41 
42  return jacobi;
43 
44 }
45 
46 TMatrixD propagate_covariance(TVectorD(*f)(TVectorD,string),
47  TVectorD x, TMatrixD xcov,
48  string stringtype)
49 {
50  int ncol = x.GetNoElements();
51  TVectorD dx(ncol);
52 
53  for (int i = 0; i < ncol; ++i)
54  dx[i] = xcov[i][i] ? sqrt(xcov[i][i]) * 1e-3 : 1;
55 
56  TMatrixD jacobi = jacobian(f, x, dx, stringtype);
57  TMatrixD jacT(TMatrixD::kTransposed, jacobi);
58  TMatrixD final = jacobi * (xcov * jacT);
59 
60  return final; //jacobi * (xcov * jacT);
61 
62 }
63 
64 
TMatrixD jacobian(TVectorD(*f)(TVectorD, const modeltype), TVectorD x, TVectorD dx, const modeltype mtype)
Definition: Statistics.icc:10
void poisson_uncertainty(double x, double &plow, double &pup)
Definition: Statistics.icc:1
a second level trigger
Definition: XbT2.h:8
TMatrixD propagate_covariance(TVectorD(*f)(TVectorD, const modeltype), TVectorD x, TMatrixD xcov, const modeltype mtype)
Definition: Statistics.icc:50

, generated on Tue Sep 26 2023.