-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Gamma function and related functions. -- -- Approximations of the gamma function, incomplete gamma functions, beta -- function, and factorials. @package gamma @version 0.7 -- | Stirling's approximation to the gamma function and utility functions -- for selecting coefficients. module Math.Gamma.Stirling -- | Convergent when Re(z) > 0. The first argument is the c_n series to -- use (cs is an ineffecient but generic definition of the full -- infinite series. Some precomputed finite prefix of cs should be -- fed to this function, the length of which will determine the accuracy -- achieved.) lnGammaStirling :: (Floating a) => [a] -> a -> a -- | The c_n series in the convergent version of Stirling's approximation -- given on wikipedia at -- http://en.wikipedia.org/wiki/Stirling%27s_approximation#A_convergent_version_of_Stirling.27s_formula -- as fetched on 11 June 2010. cs :: (Fractional a, Ord a) => [a] -- | The (signed) Stirling numbers of the first kind. s :: Int -> Int -> Integer -- | The (unsigned) Stirling numbers of the first kind. abs_s :: Int -> Int -> Integer -- | Compute the number of terms required to achieve a given precision for -- a given value of z. The mamimum will typically (always?) be around 1, -- and seems to be more or less independent of the precision desired -- (though not of the machine epsilon - essentially, near zero I think -- this method is extremely numerically unstable). terms :: (Num t, Floating a, Ord a) => a -> a -> t -- | Lanczos' approximation to the gamma function, as described at -- http://en.wikipedia.org/wiki/Lanczos_approximation (fetched 11 June -- 2010). -- -- Constants to be supplied by user. There is a file -- "extras/LanczosConstants.hs" in the source repository that implements -- a technique by Paul Godfrey for calculating the coefficients. It is -- not included in the distribution yet because it makes use of a linear -- algebra library I have not yet released (though I eventually intend -- to). module Math.Gamma.Lanczos -- | Compute Lanczos' approximation to the gamma function, using the -- specified constants. Valid for Re(x) > 0.5. Use reflect or -- reflectC to extend to the whole real line or complex plane, -- respectively. gammaLanczos :: (Floating a) => a -> [a] -> a -> a -- | Compute Lanczos' approximation to the natural logarithm of the gamma -- function, using the specified constants. Valid for Re(x) > 0.5. Use -- reflectLn or reflectLnC to extend to the whole real line -- or complex plane, respectively. lnGammaLanczos :: (Floating a) => a -> [a] -> a -> a -- | Extend an approximation of the gamma function from the domain x > -- 0.5 to the whole real line. reflect :: (RealFloat a, Ord a) => (a -> a) -> a -> a -- | Extend an approximation of the gamma function from the domain Re(x) -- > 0.5 to the whole complex plane. reflectC :: (RealFloat a) => (Complex a -> Complex a) -> Complex a -> Complex a -- | Extend an approximation of the natural logarithm of the gamma function -- from the domain x > 0.5 to the whole real line. reflectLn :: (RealFloat a, Ord a) => (a -> a) -> a -> a -- | Extend an approximation of the natural logarithm of the gamma function -- from the domain Re(x) > 0.5 to the whole complex plane. reflectLnC :: (RealFloat a) => (Complex a -> Complex a) -> Complex a -> Complex a module Math.Gamma.Incomplete -- | Continued fraction representation of the lower incomplete gamma -- function. lowerGammaCF :: (Floating a, Ord a) => a -> a -> CF a -- | Continued fraction representation of the regularized lower incomplete -- gamma function. pCF :: (Gamma a, Ord a, Enum a) => a -> a -> CF a -- | Lower incomplete gamma function, computed using Kummer's confluent -- hypergeometric function M(a;b;x). Specifically, this uses the -- identity: -- -- gamma(s,x) = x**s * exp (-x) / s * M(1; 1+s; x) -- -- From Abramowitz & Stegun (6.5.12). -- -- Recommended for use when x < s+1 lowerGammaHypGeom :: (Floating b) => b -> b -> b -- | Natural logarithm of lower gamma function, based on the same identity -- as lowerGammaHypGeom and evaluated carefully to avoid overflow -- and underflow. Recommended for use when x < s+1 lnLowerGammaHypGeom :: (Floating a) => a -> a -> a -- | Regularized lower incomplete gamma function, computed using Kummer's -- confluent hypergeometric function. Uses same identity as -- lowerGammaHypGeom. -- -- Recommended for use when x < s+1 pHypGeom :: (Gamma a, Ord a) => a -> a -> a -- | Continued fraction representation of the upper incomplete gamma -- function. Recommended for use when x >= s+1 upperGammaCF :: (Floating a, Ord a) => a -> a -> CF a -- | Natural logarithms of the convergents of the upper gamma function, -- evaluated carefully to avoid overflow and underflow. Recommended for -- use when x >= s+1 lnUpperGammaConvergents :: (Floating a) => a -> a -> [a] -- | Continued fraction representation of the regularized upper incomplete -- gamma function. Recommended for use when x >= s+1 qCF :: (Gamma a, Ord a, Enum a) => a -> a -> CF a module Math.Gamma -- | Gamma function. Minimal definition is ether gamma or -- lnGamma. class (Floating a) => Gamma a gamma :: (Gamma a) => a -> a lnGamma :: (Gamma a) => a -> a lnFactorial :: (Gamma a, Integral b) => b -> a -- | Factorial function class (Num a) => Factorial a factorial :: (Factorial a, Integral b) => b -> a -- | Incomplete gamma functions. class (Gamma a) => IncGamma a lowerGamma :: (IncGamma a) => a -> a -> a lnLowerGamma :: (IncGamma a) => a -> a -> a p :: (IncGamma a) => a -> a -> a upperGamma :: (IncGamma a) => a -> a -> a lnUpperGamma :: (IncGamma a) => a -> a -> a q :: (IncGamma a) => a -> a -> a -- | The beta function: beta z w == gamma z * gamma w / gamma -- (z+w) beta :: (Gamma a) => a -> a -> a instance Factorial Double instance Factorial Float instance Factorial Integer instance IncGamma Double instance IncGamma Float instance Gamma (Complex Double) instance Gamma (Complex Float) instance Gamma Double instance Gamma Float