How to obtain the inverse of the F cumulative distribution based on the F cumulative distribution? I am currently implementing a application that needs to obtain the inverse of the F (Fisher-Snedecor) cumulative distribution.
I already have a library that contains the F distribution and I can easily obtain the cumulative distribution based on a confidence interval and degrees of freedom.
How can I easly adapt this library to return the INVERSE of the F cumulative distribution?
 A: Let $B$ be the inverse CDF of a Beta$(n/2,m/2)$ distribution.  The inverse CDF of an $F(m,n)$ distribution evaluated at $\alpha$ equals
$$\frac{n}{m}\left(\frac{1}{B(1-\alpha)}-1\right).$$

This graphic plots the inverse CDF of an $F(2,3)$ distribution and the graph of the preceding expression.  The curves coincide.
Source: Johnson & Kotz, Continuous Univariate Distributions--2 (1970), chapter 26.2.
A: It is also possible to just pick out the F-value using the F cumulative distribution function. The idea is the following:  


*

*Define an initial interval  where the F-value should be, e.g. [0 1000]

*Subdivide the interval in smaller intervals, e.g. [0 100], (100 200],...,(900 1000]

*Calculate for each interval boundary the corresponding p-values.  


*

*[fcdf(0) fcdf(100)], (fcdf(100) fcdf(200)],...,(fcdf(900) fcdf(1000)]  

*Check which of these intervals contains the input p-value


*Then take only the interval containing the input p-value and subdivide again, e.g.
[0 10], (10 20], ...,(90 100]

*Repeat the steps 1) to 4) until the required precision is reached.


The intervals should look like this in order to converge fast:
[0 100], (100 200],...,(900 1000]
[0 10], (10 20], ...,(90 100]
[0 1], (1 2], ...,(9 10]
[0 0.1], (0.1 0.2], ...,(0.9 1.0]
[0 0.01], (0.01 0.02], ...,(0.09 0.1]
etc.

Here is an example Matlab code:
function FValue = GetFcorrespondingToP(PValue, DFNumerator, ...
    DFDenominator, Precision)

PrevFValue = 0;
NextFValue = 1000;
PrevPValue = fcdf(PrevFValue, DFNumerator, DFDenominator);
NextPValue = fcdf(NextFValue, DFNumerator, DFDenominator);
CurrPrecision = 100;
PreviousStep = 100.0;

% Security: Check if the p-value is in the interval.
if(PValue <= NextPValue && PValue >= PrevPValue)

while CurrPrecision > Precision

    % Create vector with the calculation steps.
    StepVector = PrevFValue:PreviousStep:NextFValue;
    NumSteps = length(StepVector);

    % Search for the interval containing the required p-value.
    for i = 1:NumSteps-1

        PrevPValue = fcdf(StepVector(i), DFNumerator, DFDenominator);
        NextPValue = fcdf(StepVector(i+1), DFNumerator, DFDenominator);
        if(PrevPValue <= PValue && NextPValue >= PValue)

            PrevFValue = StepVector(i);
            NextFValue = StepVector(i+1);
            break;

        end

    end

    % Set the new step and the new precision.
    CurrPrecision = CurrPrecision / 10.0;
    PreviousStep = PreviousStep / 10.0;

end

FValue = (PrevFValue + NextFValue) / 2.0;

% In the case that the wanted F-value is outside the interval [0 1000] the
% output is set to 1000. This could happen if the input p-value is e.g. 1.
else

    FValue = NextFValue;

end

