incbet

sherpa.utils.incbet(a, b, x)

Calculate the incomplete Beta function

The function is defined as:

sqrt(a+b)/(sqrt(a) sqrt(b)) Int_0^x t^(a-1) (1-t)^(b-1) dt

and the integral from x to 1 can be obtained using the relation:

1 - incbet(a, b, x) = incbet(b, a, 1-x)
Parameters:
  • a (scalar or array) – a > 0
  • b (scalar or array) – b > 0
  • x (scalar or array) – 0 <= x <= 1
Returns:

val

Return type:

scalar or array

See also

calc_ftest()
Compare two models using the F test.

Notes

In this implementation, which is provided by the Cephes Math Library [1], the integral is evaluated by a continued fraction expansion or, when b*x is small, by a power series.

Using IEEE arithmetic, the relative errors are (tested uniformly distributed random points (a,b,x) with a and b in ‘domain’ and x between 0 and 1):

domain # trials peak rms
0,5 10000 6.9e-15 4.5e-16
0,85 250000 2.2e-13 1.7e-14
0,1000 30000 5.3e-12 6.3e-13
0,1000 250000 9.3e-11 7.1e-12
0,100000 10000 8.7e-10 4.8e-11

Outputs smaller than the IEEE gradual underflow threshold were excluded from these statistics.

References

[1]Cephes Math Library Release 2.0: April, 1987. Copyright 1985, 1987 by Stephen L. Moshier. Direct inquiries to 30 Frost Street, Cambridge, MA 02140.

Examples

>>> incbet(0.3, 0.6, 0.5)
0.68786273145845922
>>> incbet([0.3,0.3], [0.6,0.7], [0.5,0.4])
array([ 0.68786273,  0.67356524])