Example: The Probability Distribution Functions
Examples of the probability distribution functions are exercised. Their use in this example typifies the manner in which other functions in the
Pdf
class would be used.
using System;
using Pdf = Imsl.Stat.Pdf;
public class PdfEx1
{
public static void Main(String[] args)
{
// Beta
double x = .5;
double pin = 12.0;
double qin = 12.0;
double result = Pdf.Beta(x, pin, qin);
Console.Out.WriteLine("Pdf.Beta(.5, 12., 12.) is {0,5:0.0000}", result);
// binomial
int k = 3;
int n = 5;
double prob = .95;
result = Pdf.Binomial(k, n, prob);
Console.Out.WriteLine("Pdf.Binomial(3, 5, .95) is " + result);
// Chi
prob = .99;
n = 2;
result = Pdf.Chi(prob, n);
Console.Out.WriteLine("Pdf.Chi(.99, 2) is {0,5:0.0000}", result);
}
}
Output
Pdf.Beta(.5, 12., 12.) is 3.8683
Pdf.Binomial(3, 5, .95) is 0.021434375
Pdf.Chi(.99, 2) is 0.3048
Link to C# source.