Example: Inverse of a User-Supplied Cumulative Distribution Function

In this example, InverseCdf is used to compute the point such that the probability is 0.9 that a standard normal random variable is less than or equal to the computed point.
import com.imsl.stat.*;

public class InverseCdfEx1 implements CdfFunction {
    public double cdf(double x) {
        return Cdf.normal(x);
    }
    
    public static void main(String args[]) throws 
    InverseCdf.DidNotConvergeException {
        double x1, p;
        
        p = 0.9;;
        InverseCdfEx1 invcdf = new InverseCdfEx1();
        InverseCdf inv = new InverseCdf(invcdf);
        inv.setTolerance(1.0e-10);
        x1 = inv.eval(p, 0.0);
        System.out.println("The 90th percentile of a standard normal is "+x1);
    }
}

Output

The 90th percentile of a standard normal is 1.2815515655446006
Link to Java source.