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