Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
std.mathspecial
Mathematical Special Functions
The technical term 'Special Functions' includes several families of
transcendental functions, which have important applications in particular
branches of mathematics and physics.
The gamma and related functions, and the error function are crucial for
mathematical statistics.
The Bessel and related functions arise in problems involving wave propagation
(especially in optics).
Other major categories of special functions include the elliptic integrals
(related to the arc length of an ellipse), and the hypergeometric functions.
Status: Many more functions will be added to this module. The naming convention for the distribution functions (gammaIncomplete, etc) is not yet finalized and will probably change.
License:
Authors:
Stephen L. Moshier (original C code). Conversion to D by Don Clugston
Source: std/mathspecial.d
- pure nothrow @nogc @safe real
gamma
(realx
); - The Gamma function, Γ(
x
)Γ(x
) is a generalisation of the factorial function to real and complex numbers. Likex
!, Γ(x
+1) =x
* Γ(x
). Mathematically, if z.re > 0 then Γ(z) = ∫0∞ tz-1e-t dtSpecial Values x
Γ( x
)NAN NAN ±0.0 ±∞ integer > 0 ( x
-1)!integer < 0 NAN +∞ +∞ -∞ NAN - pure nothrow @nogc @safe real
logGamma
(realx
); - Natural logarithm of the gamma function, Γ(
x
)Returns the base e (2.718...) logarithm of the absolute value of the gamma function of the argument. For reals,logGamma
is equivalent to log(fabs(gamma(x
))).Special Values x
logGamma
(x
)NAN NAN integer <= 0 +∞ ±∞ +∞ - pure nothrow @nogc @safe real
sgnGamma
(realx
); - The sign of Γ(
x
).Returns -1 if Γ(x
) < 0, +1 if Γ(x
) > 0, NAN if sign is indeterminate. Note that this function can be used in conjunction with logGamma(x
) to evaluate gamma for very large values ofx
. - pure nothrow @nogc @safe real
beta
(realx
, realy
); - Beta functionThe
beta
function is defined asbeta
(x
,y
) = (Γ(x
) * Γ(y
)) / Γ(x
+y
) - pure nothrow @nogc @safe real
digamma
(realx
); - Digamma functionThe
digamma
function is the logarithmic derivative of the gamma function.digamma
(x
) = d/dx logGamma(x
)See Also: - pure nothrow @nogc @safe real
logmdigamma
(realx
); - Log Minus Digamma function
logmdigamma
(x
) = log(x
) - digamma(x
)See Also: - pure nothrow @nogc @safe real
logmdigammaInverse
(realx
); - Inverse of the Log Minus Digamma functionGiven y, the function finds
x
such log(x
) - digamma(x
) = y.See Also: - pure nothrow @nogc @safe real
betaIncomplete
(reala
, realb
, realx
); - Incomplete beta integralReturns incomplete beta integral of the arguments, evaluated from zero to
x
. The regularized incomplete beta function is defined asbetaIncomplete
(a
,b
,x
) = Γ(a
+b
) / ( Γ(a
) Γ(b
) ) * ∫0x
ta
-1(1-t)b
-1 dt and is the same as the the cumulative distribution function. The domain of definition is 0 <=x
<= 1. In this implementationa
andb
are restricted to positive values. The integral fromx
to 1 may be obtained by the symmetry relation betaIncompleteCompl(a
,b
,x
) =betaIncomplete
(b
,a
, 1-x
) The integral is evaluated bya
continued fraction expansion or, whenb
*x
is small, bya
power series. - pure nothrow @nogc @safe real
betaIncompleteInverse
(reala
, realb
, realy
); - Inverse of incomplete beta integralGiven
y
, the function finds x such that betaIncomplete(a
,b
, x) ==y
Newton iterations or interval halving is used. - pure nothrow @nogc @safe real
gammaIncomplete
(reala
, realx
);
pure nothrow @nogc @safe realgammaIncompleteCompl
(reala
, realx
); - Incomplete gamma integral and its complementThese functions are defined by
gammaIncomplete
= ( ∫0x
e-t ta
-1 dt )/ Γ(a
)gammaIncompleteCompl
(a
,x
) = 1 -gammaIncomplete
(a
,x
) = (∫x
∞ e-t ta
-1 dt )/ Γ(a
) In this implementation both arguments must be positive. The integral is evaluated by eithera
power series or continued fraction expansion, depending on the relative values ofa
andx
. - pure nothrow @nogc @safe real
gammaIncompleteComplInverse
(reala
, realp
); - Inverse of complemented incomplete gamma integralGiven
a
andp
, the function finds x such that gammaIncompleteCompl(a
, x ) =p
. - pure nothrow @nogc @safe real
erf
(realx
); - Error functionThe integral is
erf
(x
) = 2/ √(π) ∫0x
exp( - t2) dt The magnitude ofx
is limited to about 106.56 for IEEE 80-bit arithmetic; 1 or -1 is returned outside this range. - pure nothrow @nogc @safe real
erfc
(realx
); - Complementary error function
erfc
(x
) = 1 - erf(x
) = 2/ √(π) ∫x
∞ exp( - t2) dt This function has high relative accuracy for values ofx
far from zero. (For values near zero, use erf(x
)). - pure nothrow @nogc @safe real
normalDistribution
(realx
); - Normal distribution function.The normal (or Gaussian, or bell-shaped) distribution is defined as: normalDist(
x
) = 1/√(2π) ∫-∞x
exp( - t2/2) dt = 0.5 + 0.5 * erf(x
/sqrt(2)) = 0.5 * erfc(-x
/sqrt(2)) To maintain accuracy at values ofx
near 1.0, usenormalDistribution
(x
) = 1.0 -normalDistribution
(-x
).References: http://www.netlib.org/cephes/ldoubdoc.html, G. Marsaglia, "Evaluating the Normal Distribution", Journal of Statistical Software 11, (July 2004).
- pure nothrow @nogc @safe real
normalDistributionInverse
(realp
); - Inverse of Normal distribution functionReturns the argument, x, for which the area under the Normal probability density function (integrated from minus infinity to x) is equal to
p
.Note: This function is only implemented to 80 bit precision.
Copyright © 1999-2017 by the D Language Foundation | Page generated by
Ddoc on Wed Jul 19 22:18:25 2017