What this tool does
This generator produces a list of pseudo-random numbers drawn from a chi-squared distribution with a chosen number of degrees of freedom, written \(v\) (the Greek letter nu). The chi-squared distribution is fundamental in statistics: it describes the sum of squared independent standard-normal variables and underlies chi-squared goodness-of-fit tests, variance estimation, and confidence intervals.
How to use it
Enter the degrees of freedom \(v\) (any positive real number, default 3), the number of random values you want (1 to 1000, default 10), and pick how many significant digits each value should display. Click calculate to get a fresh sample. Because the generator is random, every run gives different numbers, but the theoretical mean (\(v\)), variance (\(2v\)) and standard deviation (\(\sqrt{2v}\)) shown alongside are fixed and let you sanity-check the sample.
The formula explained
The chi-squared density is $$f(x,v) = \frac{x^{v/2-1}\, e^{-x/2}}{2^{v/2}\,\Gamma(v/2)}, \quad x \geq 0.$$ To draw samples we use the fact that a chi-squared(\(v\)) variable equals 2 times a Gamma variable with shape \(v/2\) and scale 1. For integer \(v\) we use the simpler identity $$X = Z_1^2 + Z_2^2 + \cdots + Z_v^2,$$ where each \(Z\) is a standard normal generated by the Box-Muller transform. For non-integer \(v\) we use the Marsaglia-Tsang gamma method and then multiply by 2.
Worked example
With \(v = 3\) and count = 10, each value is the sum of three squared standard normals. A representative sample might be 1.842, 4.317, 0.526, 2.991, 6.083, 1.205, 3.778, 0.914, 5.460, 2.337. Their average is about 2.945, close to the theoretical mean of 3. Every value is non-negative, as required.
FAQ
Why do my numbers change each time? The generator uses a random source, so each run produces an independent sample. The theoretical statistics stay the same.
Can \(v\) be a decimal? Yes. Any \(v\) greater than 0 is valid; the tool uses the gamma method for non-integer values.
What if I ask for more than 1000 values? The count is clamped to the allowed range of 1 to 1000.