Qu

chisquare

Builtin index · Statistics & ML

result = chisquare(k, [rows], [cols], [seed=])

Input: k, rows, cols, seed · Output: result

What it is

Draws from the chi-square distribution with k degrees of freedom (a positive integer), same rows/cols/seed= shape as rand.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = chisquare(k, [rows], [cols], [seed=])
k —not documented yet
rows optionalnot documented yet
cols optionalnot documented yet
seed optionalnot documented yet
result number, vector, or matrix
Returns a number, vector, or (rows, cols) matrix.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

x = chisquare(4, 1000, seed=1)
print("sample mean: {mean(x)}")   # converges to k=4, the distribution's own mean

output
sample mean: 4.108075

from numerics-dsp

How it works

chisquare(k, ...) — sum of k squared standard-normal draws, the direct construction of chi-square with k degrees of freedom; see Rng::chi_square's doc comment.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.