def reg_incomplete_beta(a, b, x):
if (x == <NUM_LIT:0>):<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>elif (x == <NUM_LIT:1>):<EOL><INDENT>return <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>lbeta = (math.lgamma(a + b) - math.lgamma(a) - math.lgamma(b) +<EOL>a * math.log(x) + b * math.log(<NUM_LIT:1> - x))<EOL>if (x < (a + <NUM_LIT:1>) / (a + b + <NUM_LIT:2>)):<EOL><INDENT>return math.exp(lbeta) * __contfractbeta(a, b, x) / a<EOL><DEDENT>else:<EOL><INDENT>return <NUM_LIT:1> - math.exp(lbeta) * __contfractbeta(b, a, <NUM_LIT:1> - x) / b<EOL><DEDENT><DEDENT>
Incomplete beta function; code translated from: Numerical Recipes in C.

:param a: a > 0
:param b: b > 0
:param x: 0 <= x <= 1.