Incomplete Beta Integral using fraction expansion method #1

You're viewing an older version of this page (#122). View the current version.

View versions (3)

Interface

Overview

The incomplete Beta Integral calculated using method 1 of fraction expansion approach.

Parameters

x
upper limit of integration. (0<x<1)
a
first shape argument, must be positive.
b
second shape argument, must be positive.
GPL Licence — free for non commercial use. See Licence details.

FUNCTION

betaLower_expn2

The incomplete Beta Integral calculated using method 2 of the fraction expansion approach.

Parameters

x
upper limit of integration (0<x<1)
a
first shape argument, must be positive
b
second shape argument, must be positive

Interactive Calculator

x
a
b
Result

FUNCTION

betaLower_reg_pow

Power series for the regularized incomplete beta integral,B_x(a,b), Use when b x is small and x is not too close to 1.

Parameters

x
upper limit of integration (0<x<1)
a
first shape argument, must be positive
b
second shape argument, must be positive
Author

Stephen L.Moshier. Copyright 1984, 1987, 1989, 1992, 2000

Interactive Calculator

x
a
b
Result

FUNCTION

beta_reg

Returns the regularized incomplete beta integral of the arguments, evaluated from zero to x. This is occasionally also called the beta function ratio, given that it returns the probability that a random variable drawn from a beta distribution with parameters a and b will be less that or equal to x.

This ratio/regularization is calculated by dividing the incomplete beta integral by the complete beta integral, i.e.

If the incomplete beta integral is defined by:

B_z(a,b) = \int_0^x t^{a-1} (1-t)^{b-1} dt
(1)

and the complete beta integral is defined by:

\frac{\Gamma(a) \Gamma(b)}{\Gamma(a+b)}
(2)

where \Gamma is the Gamma function.

Then the regularized beta integral is:

\frac{\Gamma(a+b)}{\Gamma(a) \Gamma(b)} * B_x(a,b)
(3)

where B_x(a,b).

The domain of definition is 0 <= x <= 1. In this implementation a and b are restricted to positive values. The integral from x to 1 may be obtained by the symmetry relation, i.e.

1 - beta_reg( x, a, b )  =  beta_reg( 1-x, a, b ).

The integral is evaluated by a continued fraction expansion or, when b x is small, by a power series.

Accuracy:

Tested at uniformly distributed random points (x,a,b) with a and b in "domain" and x between 0 and 1. <pre> Relative error 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,10000 250000 9.3e-11 7.1e-12 0,100000 10000 8.7e-10 4.8e-11 </pre>

Error Messages:

* message condition value returned * beta_reg domain x<0, x>1 0.0 * beta_reg underflow 0.0

Example:

The following example evaluates the upper regularized incomplete beta integral for 10 points equally spaced in the interval from 0 to 1.

#include <stdio.h>
#include <codecogs/maths/special/gamma/beta_reg.h>
void main()
{
  for (double x=0; x<1; x+=0.1)
  {
    double y = Maths::Special::Gamma::beta_reg(x, 2, 1, true);
    printf("beta_reg(2, %.1lf, 1, true) = %lf\n", x,y);
  }
}

Output:

beta_reg(2, 0.0, 1, true) = 1.000000
beta_reg(2, 0.1, 1, true) = 0.990000
beta_reg(2, 0.2, 1, true) = 0.960000
beta_reg(2, 0.3, 1, true) = 0.910000
beta_reg(2, 0.4, 1, true) = 0.840000
beta_reg(2, 0.5, 1, true) = 0.750000
beta_reg(2, 0.6, 1, true) = 0.640000
beta_reg(2, 0.7, 1, true) = 0.510000
beta_reg(2, 0.8, 1, true) = 0.360000
beta_reg(2, 0.9, 1, true) = 0.190000
beta_reg(2, 1.0, 1, true) = 0.000000

Parameters

x
the value at which to evaluate the function, must be in range 0..1
a
the 1st number of degrees of freedom, must be strictly positive
b
the 2nd number of degrees of freedom, must be strictly positive
upper
Default value = false
Author

Stephen L.Moshier. Copyright 1984, 1987, 1989, 1992, 2000

Interactive Calculator

x
a
b
upper
Result