Computing the odds of a distribution being random

Now that we have the incomplete gamma function, gamma, and the complete gamma function, Gamma_Half, we can compute the  CDF values. This value shows us the odds of a given value being random or having some possible correlation.

The function itself is quite small:

def cdf(x: Union[Fraction, float], k: int) -> Fraction:    """X² cumulative distribution function.
    :param x: X² value, sum (obs[i]-exp[i])**2/exp[i]
        for parallel sequences of observed and expected values.    :param k: degrees of freedom >= 1; often len(data)-1
    """
    return (        1 -         gamma(Fraction(k, 2), Fraction(x/2)) / Gamma_Half(Fraction(k, ...

Get Functional Python Programming - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.