Special Functions Example (C#)
[C#]
/* COPYRIGHT(C), SIMPLEXAR SOFTWARE LIMITED, 2006-2008.
* All rights reserved.
*
* Use of this copyright notice is precautionary only, and does not imply
* publication or disclosure. The content of this work contains confidential
* and proprietary information of Simplexar Software Limited. Any duplication,
* modification, distribution, or disclosure in any form, in whole, or in part,
* is strictly prohibited without express prior written permission.
*/
// Get namespaces.
using System;
using Simplexar.Statsar;
// Start namespace.
namespace Simplexar.Examples.Statsar
{
/// <summary>
/// This example uses the statistics calculator to evaluate
/// special functions (e.g. binomial coefficients and gamma functions).
/// </summary>
public static class Example
{
/// <summary>
/// The application entry point.
/// </summary>
public static void Main()
{
try
{
RunExample();
}
catch(Exception exception)
{
Console.WriteLine(exception);
}
Console.WriteLine("Press ENTER to terminate.");
Console.ReadLine();
}
private static void RunExample()
{
// Create a calculator.
StatsCalculator calculator = new StatsCalculator();
// Evaluate special functions.
Console.WriteLine("Factorial(3) = {0}",
calculator.Factorial(3));
Console.WriteLine("LogFactorial(50) = {0}",
calculator.LogFactorial(50));
Console.WriteLine("Binomial(5, 3) = {0}",
calculator.Binomial(5, 3));
Console.WriteLine("LogBinomial(13, 6) = {0}",
calculator.LogBinomial(13, 6));
Console.WriteLine("Gamma(-3.5) = {0}",
calculator.Gamma(-3.5));
Console.WriteLine("LogGamma(4.5) = {0}",
calculator.LogGamma(4.5));
Console.WriteLine("IncompleteGammaP(3.6, 6.4) = {0}",
calculator.IncompleteGammaP(3.6, 6.4));
Console.WriteLine("IncompleteGammaQ(2.4, 4.6) = {0}",
calculator.IncompleteGammaQ(2.4, 4.6));
Console.WriteLine("Beta(0.5, 0.6) = {0}",
calculator.Beta(0.5, 0.6));
Console.WriteLine("LogBeta(-3.5, 12) = {0}",
calculator.LogBeta(-3.5, 12));
Console.WriteLine("IncompleteBeta(0.3, 0.5, 0.8) = {0}",
calculator.IncompleteBeta(0.3, 0.5, 0.8));
Console.WriteLine("Erf(-0.8) = {0}",
calculator.Erf(-0.8));
}
}
}