Statistics.icc
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, const modeltype),
11  TVectorD x, TVectorD dx,
12  const modeltype mtype)
13 {
14 
15  int nx = x.GetNoElements();
16  TVectorD y = f(x, mtype);
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, mtype);
30  TVectorD t2 = f(x, mtype);
31  TVectorD tmp = (f(x + e, mtype) - f(x, mtype));
32 
33  TVectorD der = tmp;
34 
35  //cout << e[ix] << "\t" << t1[ix] <<"\t" << t2[ix] << "\t" << tmp[ix]/dx[ix] << endl;
36 
37  for (int iy = 0; iy < ny; ++iy) {
38  jacobi[iy][ix] = der[iy] / dx[ix]; // if ny > 1 else der
39 
40  //cout << jacobi[iy][ix] << endl;
41  }
42 
43 
44  }
45 
46  return jacobi;
47 
48 }
49 
50 TMatrixD propagate_covariance(TVectorD(*f)(TVectorD, const modeltype),
51  TVectorD x, TMatrixD xcov,
52  const modeltype mtype)
53 {
54  int ncol = x.GetNoElements();
55  TVectorD dx(ncol);
56 
57  for (int i = 0; i < ncol; ++i)
58  dx[i] = xcov[i][i] ? sqrt(xcov[i][i]) * 1e-3 : 1;
59 
60  TMatrixD jacobi = jacobian(f, x, dx, mtype);
61  TMatrixD jacT(TMatrixD::kTransposed, jacobi);
62  TMatrixD final = jacobi * (xcov * jacT);
63 
64  return final; //jacobi * (xcov * jacT);
65 
66 }
67 
68 
TMatrixD jacobian(TVectorD(*f)(TVectorD, const modeltype), TVectorD x, TVectorD dx, const modeltype mtype)
Definition: Statistics.icc:10
modeltype
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.