Statistics/Chi-squared distribution: Difference between revisions
Content added Content deleted
m (cleanup) |
m (change function names to reflect text at top) |
||
Line 96: | Line 96: | ||
end |
end |
||
""" lower incomplete gamma function, using MPFR library to get upper incomplete gamma """ |
""" gamma CDF from lower incomplete gamma function, using MPFR library to get upper incomplete gamma """ |
||
function |
function gamma_cdf(a, x) |
||
z, biga, bigx = BigFloat(), BigFloat(a), BigFloat(x) |
z, biga, bigx = BigFloat(), BigFloat(a), BigFloat(x) |
||
ccall((:mpfr_gamma_inc, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Ref{BigFloat}, Int32), z, biga, bigx, 0) |
ccall((:mpfr_gamma_inc, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Ref{BigFloat}, Int32), z, biga, bigx, 0) |
||
Line 105: | Line 105: | ||
""" Cumulative probability function (cdf) for chi-squared """ |
""" Cumulative probability function (cdf) for chi-squared """ |
||
function cdf_χ2(x, k) |
function cdf_χ2(x, k) |
||
return x <= 0 || k <= 0 ? 0.0 : |
return x <= 0 || k <= 0 ? 0.0 : gamma_cdf(k / 2, x / 2) |
||
end |
end |
||