0

I am working in python. I have a function for incomplete beta. Iow would I calculate tCDF and invT using this? the incomplete beta function that I have is this:

def incBeta(a, b, x):

    # Shortcut special cases
    if (x == 0):
        return 0;
    elif (x == 1):
        return 1;

    # otherwise calculate things.
    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;

How do I calculate the tcdf and invT using the value returned from this?

  • You cannot directly compute the inverse CDF with the incomplete Beta function: you need its inverse for that. – whuber Jun 05 '19 at 01:09
  • @whuber ok so how do you do CDF with it? the question you marked it as duplicating isn't helpful as it only shows it in C and not everyone can read C. also as I said, i have the incomplete beta function but I need the tCDF in terms of a predefined incbeta. I believe you have misunderstood the question but that may be my fault. Im not asking for the incomplete beta function. I have that. I need tCDF from that in the same way normalCDF is defined in terms of erf(x) – Matthew Morrissette Jun 05 '19 at 02:32
  • The duplicate clearly shows how the Student t CDF is expressed in terms of the incomplete Beta function. It does so first in mathematical notation and then in C, which is so close to Python you should have no trouble at all implementing it. It also provides a link to a detailed description of the underlying mathematics on the Numerical Recipes site, where you can find implementations in many languages. – whuber Jun 05 '19 at 11:49

0 Answers0