Example: The Cumulative Distribution Functions
Various cumulative distribution functions are exercised. Their use in this example typifies the manner in which other functions in the Cdf class would be used.
using System;
using Imsl.Stat;
public class CdfEx1
{
public static void Main(String[] args)
{
double x, prob, result;
int p, q, k, n;
// Beta
x = .5;
p = 12;
q = 12;
result = Cdf.Beta(x, p, q);
Console.Out.WriteLine("Cdf.Beta(.5, 12, 12) is " + result);
// binomial
k = 3;
n = 5;
prob = .95;
result = Cdf.Binomial(k, n, prob);
Console.Out.WriteLine("Cdf.Binomial(3, 5, .95) is " + result);
// Chi
x = .15;
n = 2;
result = Cdf.Chi(x, n);
Console.Out.WriteLine("Cdf.Chi(.15, 2) is " + result);
}
}
Output
Cdf.Beta(.5, 12, 12) is 0.500000000000002
Cdf.Binomial(3, 5, .95) is 0.0225925
Cdf.Chi(.15, 2) is 0.0722565136714471
Link to C# source.