PRD2020/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 void FC_UpperLimits(double x, double& plow, double& pup)
9 {
10 
11  TFeldmanCousins *ff = new TFeldmanCousins (0.90,"");
12  Double_t Nobserved = x;
13  Double_t Nbackground = 0.0;
14  Double_t ul = ff->CalculateUpperLimit(Nobserved, Nbackground);
15  Double_t ll = ff->GetLowerLimit();
16  plow = x - ll;
17  pup = ul - x;
18 
19 }
20 
21 
22 
23 TMatrixD jacobian(TVectorD(*f)(TVectorD, string),
24  TVectorD x, TVectorD dx,
25  string stringtype)
26 {
27 
28  int nx = x.GetNoElements();
29  TVectorD y = f(x, stringtype);
30  int ny = y.GetNoElements();
31 
32  TMatrixD jacobi(ny, nx);
33  jacobi.Zero();
34 
35  TVectorD e(nx);
36  e.Zero();
37 
38  for (int ix = 0; ix < nx; ++ix) {
39  e.Zero();
40  e[ix] = 1 * dx[ix];
41 
42  TVectorD t1 = f(x + e, stringtype);
43  TVectorD t2 = f(x, stringtype);
44  TVectorD tmp = (f(x + e, stringtype) - f(x, stringtype));
45 
46  TVectorD der = tmp;
47 
48  for (int iy = 0; iy < ny; ++iy) {
49  jacobi[iy][ix] = der[iy] / dx[ix]; // if ny > 1 else der
50  }
51 
52 
53  }
54 
55  return jacobi;
56 
57 }
58 
59 //TMatrixD propagate_covariance(TVectorD(*f)(TVectorD,TMatrixD,double*,string,TAxis *),
60 TMatrixD propagate_covariance(TVectorD(*f)(TVectorD,string),
61  TVectorD x, TMatrixD xcov,
62  string stringtype)
63 {
64  int ncol = x.GetNoElements();
65  TVectorD dx(ncol);
66 
67  for (int i = 0; i < ncol; ++i)
68  dx[i] = xcov[i][i] ? sqrt(xcov[i][i]) * 1e-3 : 1;
69 
70  TMatrixD jacobi = jacobian(f, x, dx, stringtype);
71  TMatrixD jacT(TMatrixD::kTransposed, jacobi);
72  TMatrixD final = jacobi * (xcov * jacT);
73 
74  return final; //jacobi * (xcov * jacT);
75 
76 }
77 
78 
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
#define ul(text)
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
void FC_UpperLimits(double x, double &plow, double &pup)

, generated on Tue Sep 26 2023.