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.
using System;
using Imsl.Stat;
public class InverseCdfEx1 : ICdfFunction
{
public double CdfFunction(double x)
{
return Cdf.Normal(x);
}
public static void Main(String[] args)
{
double p = 0.9; ;
ICdfFunction normal = new InverseCdfEx1();
InverseCdf inv = new InverseCdf(normal);
inv.Tolerance = 1.0e-10;
double x1 = inv.Eval(p, 0.0);
Console.Out.WriteLine
("The 90th percentile of a standard normal is " + x1);
}
}
Output
The 90th percentile of a standard normal is 1.2815515655446
Link to C# source.