/// <summary> /// Chi-squared probability density function. /// </summary> /// <param name="x">The value at which the PDF is evaluated.</param> /// <param name="k">Degress of freedom, or number independent standard normal distributions.</param> /// <returns></returns> public static double ChiSquaredProbabilityDensityFunction(double x, int k) { double g = MMath.GammaFunction(0.5 * k); double a = 1.0 / (Math.Pow(2, 0.5 * k) * g); return(a * Math.Pow(x, 0.5 * k - 1.0) * Math.Exp(-0.5 * x)); }
/// <summary> /// Returns the PDF of Student's t distribution. /// </summary> /// <param name="x">Value at which the distribution is evaluated.</param> /// <param name="k">Degrees of freedom.</param> public static double StudentsTProbabilityDensityFunction(double x, double k) { double a = MMath.GammaFunction(0.5 * k + 0.5); double b = Math.Pow(1.0 + (x * x) / k, -0.5 * k - 0.5); double c = Math.Sqrt(k * Math.PI) * MMath.GammaFunction(0.5 * k); return(a * b / c); }