Statistics/Chi-squared distribution: Difference between revisions
m
correct formula
No edit summary |
m (correct formula) |
||
Line 31:
The lower incomplete gamma function can be calculated as
<math display="block"> x^s
and so, for the chi-squared cumulative probability distribution
: <math display="block"> F(x;\,k) =
<br />
<br />
Line 96:
end
"""
function gamma_cdf(
return x^k * exp(-x) * sum(x^m / gamma(k + m + 1) for m in 0:100)
end
""" Cumulative probability function (cdf) for chi-squared """
function cdf_χ2(x, k)
return x <= 0 || k <= 0 ? 0.0 : gamma_cdf(k / 2, x / 2)
end
|