View source code
Display the source code in std/mathspecial.d from which thispage was generated on github.
Report a bug
If you spot a problem with this page, click here to create aGitHub 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 usinglocal clone.
Function std.mathspecial.betaIncomplete
Regularized incomplete beta function Ix(a,b)
real betaIncomplete(
real a,
real b,
real x
) pure nothrow @nogc @safe;
Mathematically, if a and b are positive real numbers, and 0 ≤ x ≤ 1, then Ix(a,b) = ∫0xta-1(1-t)b-1dt/B(a,b) where B is the beta function. It is also the cumulative distribution function of the beta distribution.
Parameters
| Name | Description |
|---|---|
| a | the first argument of B, must be positive |
| b | the second argument of B, must be positive |
| x | the fraction of integration completion from below, 0 ≤ x ≤ 1 |
Returns
It returns Ix(a,b), an element of [0,1].
| a | b | x | betaIncomplete(a, b, x) |
|---|---|---|---|
| negative | b | x | NAN |
| a | negative | x | NAN |
| a | b | < 0 | NAN |
| a | b | > 1 | NAN |
| +0 | +0 | (0,1) | NAN |
| ∞ | ∞ | (0,1) | NAN |
If one or more of the input parameters are NAN, the one with the largest payload is returned. For equal payloads but with possibly different signs, the order of preference is x, a, b.
Note
The integral is evaluated by a continued fraction expansion or, when b * x is small, by a
power series.
See Also
Example
writeln(betaIncomplete(1, 1, .5)); // .5
writeln(betaIncomplete(+0., +0., 0)); // 0
assert(isNaN(betaIncomplete(+0., +0., .5)));
assert(isNaN(betaIncomplete(real .infinity, real .infinity, .5)));
writeln(betaIncomplete(real .infinity, real .infinity, 1)); // 1
assert(betaIncomplete(NaN(0x1), 1, NaN(0x2)) is NaN(0x2));
assert(betaIncomplete(1, NaN(0x3), -NaN(0x3)) is -NaN(0x3));
Authors
Stephen L. Moshier (original C code). Conversion to D by Don Clugston
License
Copyright © 1999-2026 by the D Language Foundation | Page generated by ddox.