110 TGraphQQ::TGraphQQ(Int_t n, Double_t *x)
119 Int_t *index =
new Int_t[n];
120 TMath::Sort(n, x, index, kFALSE);
121 for (Int_t i=0; i<fNpoints; i++)
131 TGraphQQ::TGraphQQ(Int_t n, Double_t *x, TF1 *f)
136 Int_t *index =
new Int_t[n];
137 TMath::Sort(n, x, index, kFALSE);
138 for (Int_t i=0; i<fNpoints; i++)
143 MakeFunctionQuantiles();
150 TGraphQQ::TGraphQQ(Int_t nx, Double_t *x, Int_t ny, Double_t *y)
160 nx<=ny ? fNpoints=nx : fNpoints=ny;
162 if (!CtorAllocate())
return;
164 Int_t *index =
new Int_t[TMath::Max(nx, ny)];
165 TMath::Sort(nx, x, index, kFALSE);
167 for (Int_t i=0; i<fNpoints; i++)
169 TMath::Sort(ny, y, index, kFALSE);
171 for (Int_t i=0; i<fNpoints; i++)
177 fY0 =
new Double_t[ny];
178 for (Int_t i=0; i<ny; i++)
184 fY0 =
new Double_t[nx];
185 for (Int_t i=0; i<nx; i++)
186 fY0[i] = x[index[i]];
187 TMath::Sort(ny, y, index, kFALSE);
188 for (Int_t i=0; i<ny; i++)
200 TGraphQQ::~TGraphQQ()
211 void TGraphQQ::MakeFunctionQuantiles()
214 TString s = fF->GetTitle();
216 if (s.Contains(
"TMath::Gaus") || s.Contains(
"gaus")){
218 for (Int_t k=1; k<=fNpoints; k++){
219 pk = (k-0.375)/(fNpoints+0.25);
220 fX[k-1]=TMath::NormQuantile(pk);
223 Double_t *prob =
new Double_t[fNpoints];
225 for (Int_t k=1; k<=fNpoints; k++)
226 prob[k-1] = (k-0.5)/fNpoints;
228 for (Int_t k=1; k<=fNpoints; k++)
229 prob[k-1] = (k-0.375)/(fNpoints+0.25);
232 fF->GetQuantiles(fNpoints, fX, prob);
243 void TGraphQQ::MakeQuantiles()
251 for (Int_t i=0; i<fNpoints-1; i++){
252 pi = (fNy0-1)*Double_t(i)/Double_t(fNpoints-1);
253 pint = TMath::FloorNint(pi);
255 fX[i] = (1-pfrac)*fY0[pint]+pfrac*fY0[pint+1];
257 fX[fNpoints-1]=fY0[fNy0-1];
266 void TGraphQQ::Quartiles()
268 Double_t prob[]={0.25, 0.75};
271 TMath::Quantiles(fNpoints, 2, fY, y, prob, kTRUE);
273 TMath::Quantiles(fNy0, 2, fY0, x, prob, kTRUE);
275 TString s = fF->GetTitle();
276 if (s.Contains(
"TMath::Gaus") || s.Contains(
"gaus")){
277 x[0] = TMath::NormQuantile(0.25);
278 x[1] = TMath::NormQuantile(0.75);
280 fF->GetQuantiles(2, x, prob);
283 TMath::Quantiles(fNpoints, 2, fX, x, prob, kTRUE);
285 fXq1=x[0]; fXq2=x[1]; fYq1=y[0]; fYq2=y[1];
292 void TGraphQQ::SetFunction(TF1 *f)
295 MakeFunctionQuantiles();