Inverse FDist()?

Dear all,

I’m looking for the inverse F distribution, also called Fisher-Snedecor distribution.
The TMath::FDist() is indeed present but what about it’s inverse function?
Thank you
Davide

Hi,

I guess you need the inverse of the cumulative distribution (the quantile function). The cumulative is
TMath::DistI or ROOT::Math::fdistribution_cdf
The inverse of the cdf is available in ROOT as ROOT::Math::fdistribution_quantile and defined in the header file “Math/DistFunc.h”

see project-mathlibs.web.cern.ch/pro … 2bb4e234ec

Best Regards
Lorenzo

Thank you Lorenzo,

this was very helpful.
Actually the function that produces results close to what I expect is:
ROOT::Math::fdistribution_quantile_c.
However results are not exactly what I expect.

I’ll say better what I’m trying to do, perheaps you can help me.
I want to compute errors on an efficiency evaluation study using clopper-pearson intervals as described in PDG. Extremes of these intervals are found using a formula that includes F^-1_F which is called there the quantile of the F distribution (also called Fisher-Snedecor distribution).
I started with a few examples using an Excel worksheet which implements this function as FINV(), and now I want to implement in my root macro for a more serious job.
The point is that using the function above I get somewhat different results.
An example:
If n=838866 and N=845207:
ndof1_lo = 838866; //(n)
ndof2_lo = 6342; // (n+1)
ndof1_up = 838867; // (N-n+1)
ndof2_up = 6341; // (N-n)
I want, say, alpha=0.975 (for 97.5% C.L.)
I compute both in Excel and in ROOT
F_lo(alpha, 2ndof1_lo, 2ndof2_lo)
F_up(1-alpha, 2ndof1_up, 2ndof2_up)
In Excel I get:
F_lo = 0.975746191
F_up = 1.025171022
In ROOT I get:
F_lo = 0.965957970415720624
F_up = 1.03586997129187219

The difference seems too large to me to depend on precision or rounding issues but I’m no expert
Of course I don’t expect you to know how excels implement its functions but which one would you trust and why? Am I using the right function? (the one without ‘_c’ produce identical results for inverted values of alpha and 1-alpha as first argument)

Thanks a lot for your help
Davide

Thank you Lorenzo,

this was very helpful.
Actually the function that produces results close to what I expect is:
ROOT::Math::fdistribution_quantile_c.
However results are not exactly what I expect.

I’ll say better what I’m trying to do, perheaps you can help me.
I want to compute errors on an efficiency evaluation study using clopper-pearson intervals as described in PDG. Extremes of these intervals are found using a formula that includes F^-1_F which is called there the quantile of the F distribution (also called Fisher-Snedecor distribution).
I started with a few examples using an Excel worksheet which implements this function as FINV(), and now I want to implement in my root macro for a more serious job.
The point is that using the function above I get somewhat different results.
An example:
If n=838866 and N=845207:
ndof1_lo = 838866; //(n)
ndof2_lo = 6342; // (n+1)
ndof1_up = 838867; // (N-n+1)
ndof2_up = 6341; // (N-n)
I want, say, alpha=0.975 (for 97.5% C.L.)
I compute both in Excel and in ROOT
F_lo(alpha, 2ndof1_lo, 2ndof2_lo)
F_up(1-alpha, 2ndof1_up, 2ndof2_up)
In Excel I get:
F_lo = 0.975746191
F_up = 1.025171022
In ROOT I get:
F_lo = 0.965957970415720624
F_up = 1.03586997129187219

The difference seems too large to me to depend on precision or rounding issues but I’m no expert
Of course I don’t expect you to know how excels implement its functions but which one would you trust and why? Am I using the right function? (the one without ‘_c’ produce identical results for inverted values of alpha and 1-alpha as first argument)

Thanks a lot for your help
Davide

Hi Davide,

for calculating the Clopper Pearson interval we have introduced since one week a new class in ROOT called TEfficiency. See root.cern.ch/root/htmldoc/TEfficiency.html

The class implements a static function TEfficiency::ClopperPearson(Int_t total, Int_t passed, Double_t level, Bool_t bUpper)

for calculating the upper/lower interval. See root.cern.ch/root/htmldoc/TEffic … perPearson

We have verified the results with Mathematica, so the function seems correct. Also the F distribution is correct, we actually use directly the beta in the formula since it is simpler. The two distribution are anyway related, see
en.wikipedia.org/wiki/F-distribution

I guess you should double-check your result, using consistent value of alpha and the other parameters.
If you noticed a different result from TEfficiency::ClopperPearson please let me know

Cheers

Lorenzo

Thanks, this class is a dream come true!
Unfortunately I’m stuck with ROOT 5.20 for the moment as my data read only with that version, I hope we will move soon.
Anyhow I copied the code brutely from the static function you mention and indeed I get exaclty the same Clopper Pearson interval I was getting in Excel.
What is unclear to me is why the previous method described above does not yield the same values.
Was it any wrong?

Anyhow, thank you again, great support team.
Davide