Statistics/Chi-squared distribution: Difference between revisions
m
→{{header|Python}}: cdf function
(→{{header|Julia}}: gamma) |
m (→{{header|Python}}: cdf function) |
||
Line 308:
def χ2(x, k):
''' Chi-squared function, the probability distribution function (pdf) for chi-squared '''
return x
def gamma_cdf(k, x):
''' lower incomplete gamma by series formula with gamma '''
return x**k * exp(-x) * sum(x**m / gamma(k + m + 1) for m in range(100))
def cdf_χ2(x, k):
''' Cumulative probability function (cdf) for chi-squared '''
return gamma_cdf(k / 2, x / 2) if x
|