statistics-0.5.1.1: A library of statistical types, data, and functions

Portabilityportable
Stabilityexperimental
Maintainerbos@serpentine.com

Statistics.Math

Contents

Description

Mathematical functions for statistics.

Synopsis

Functions

chebyshevSource

Arguments

:: Double

Parameter of each function.

-> Vector Double

Coefficients of each polynomial term, in increasing order.

-> Double 

Evaluate a series of Chebyshev polynomials. Uses Clenshaw's algorithm.

choose :: Int -> Int -> DoubleSource

The binomial coefficient.

 7 `choose` 3 == 35

Factorial functions

factorial :: Int -> DoubleSource

Compute the factorial function n!. Returns ∞ if the input is above 170 (above which the result cannot be represented by a 64-bit Double).

logFactorial :: Int -> DoubleSource

Compute the natural logarithm of the factorial function. Gives 16 decimal digits of precision.

Gamma functions

incompleteGammaSource

Arguments

:: Double

s

-> Double

x

-> Double 

Compute the incomplete gamma integral function γ(s,x). Uses Algorithm AS 239 by Shea.

logGamma :: Double -> DoubleSource

Compute the logarithm of the gamma function Γ(x). Uses Algorithm AS 245 by Macleod.

Gives an accuracy of 10–12 significant decimal digits, except for small regions around x = 1 and x = 2, where the function goes to zero. For greater accuracy, use logGammaL.

Returns ∞ if the input is outside of the range (0 < x ≤ 1e305).

logGammaL :: Double -> DoubleSource

Compute the logarithm of the gamma function, Γ(x). Uses a Lanczos approximation.

This function is slower than logGamma, but gives 14 or more significant decimal digits of accuracy, except around x = 1 and x = 2, where the function goes to zero.

Returns ∞ if the input is outside of the range (0 < x ≤ 1e305).

References

  • Clenshaw, C.W. (1962) Chebyshev series for mathematical functions. National Physical Laboratory Mathematical Tables 5, Her Majesty's Stationery Office, London.
  • Lanczos, C. (1964) A precision approximation of the gamma function. SIAM Journal on Numerical Analysis B 1:86–96. http://www.jstor.org/stable/2949767
  • Macleod, A.J. (1989) Algorithm AS 245: A robust and reliable algorithm for the logarithm of the gamma function. Journal of the Royal Statistical Society, Series C (Applied Statistics) 38(2):397–402. http://www.jstor.org/stable/2348078
  • Shea, B. (1988) Algorithm AS 239: Chi-squared and incomplete gamma integral. Applied Statistics 37(3):466–473. http://www.jstor.org/stable/2347328