chi2cdf
Builtin index · Statistics & ML
result = chi2cdf(x, k)
Input: x, k · Output: result
What it is
Chi-square cumulative distribution P(X <= x) at x (a number or vector, elementwise) with k degrees of freedom.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = chi2cdf(x, k) | x number or vectornot documented yetk number or vectornot documented yet | result number or vector | Returns a number or vector in [0, 1], the same shape as x. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
p = chi2cdf(3.841459, 1) # 0.95 -- the textbook stats-table value
from numerics-dsp
print("geo = nbin(r=1): {geopdf(3, 0.2)} {nbinpdf(3, 1, 0.2)}")
print("bern = bino(n=1): {bernpdf(1, 0.3)} {binopdf(1, 1, 0.3)}")
print("chi2 = gam(k/2, 2): {chi2cdf(4.5, 3)} {gamcdf(4.5, 1.5, 2)}")
print("exp = gam(1, mu): {expcdf(2, 3)} {gamcdf(2, 1, 3)}")
print("bino -> poiss: {binocdf(3, 10000, 0.0004)} vs {poisscdf(3, 4)}")
s = hygestat(50, 10, 12)
print("hypergeometric mean {s.mean}, variance {round(s.var, 4)}")
x = gamrnd(2.5, 1.5, 5000, 1, seed = 7)
g = gamfit(x)
print("gamfit: a = {round(g.a, 2)}, b = {round(g.b, 2)}, loglik = {round(g.loglik, 1)}")
k = binoinv(0.95, 20, 0.3)
print("95% of Binomial(20, 0.3) draws are <= {k}: binocdf = {round(binocdf(k, 20, 0.3), 4)}")
output
geo = nbin(r=1): 0.1024 0.1024 bern = bino(n=1): 0.3 0.3 chi2 = gam(k/2, 2): 0.78771 0.78771 exp = gam(1, mu): 0.486583 0.486583 bino -> poiss: 0.433431 vs 0.43347 hypergeometric mean 2.4, variance 1.489 gamfit: a = 2.55, b = 1.47, loglik = -10647.1 95% of Binomial(20, 0.3) draws are <= 9: binocdf = 0.952
from statistics-ml
How it works
chi2cdf(x, k) — P(X <= x) for chi-square with k degrees of freedom: the regularized lower incomplete gamma P(k/2, x/2). Broadcasts over a vector x.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.