RANDCHISQ Function (Gnumeric)
RANDCHISQ(df) accepts nonnegative degrees of freedom, including nonintegers. For positive df, the ideal chi-square mean is df and variance 2×df; a random draw is not fixed at its mean.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: RANDCHISQ(df) accepts nonnegative degrees of freedom, including nonintegers. For positive df, the ideal chi-square mean is df and variance 2×df; a random draw is not fixed at its mean.
Syntax
=RANDCHISQ(df)
Availability and evidence
- Introduction: Gnumeric 1.1.6 NEWS explicitly lists this new function. This release-history evidence is separate from a native test of that old version.
- Source support: Registered in the Gnumeric 1.12.62 random plugin. No retirement is established; the last functioning native application version is unverified.
- Evidence dates: Official Gnumeric source retained October 13–14, 2026 was reviewed October 15. Mathematical controls were independently recalculated October 15. No native application, compiled Gnumeric helper or random generator was executed.
Parameter and source contract
The required df argument is passed as a floating-point value, without integer truncation. A negative df produces #NUM!. The helper evaluates twice a gamma variate with shape df/2 and scale 1. Its gamma helper returns 0 when shape is 0, so =RANDCHISQ(0) gives 0 as a source-defined degenerate case.
For positive df the ideal distribution is supported on nonnegative values, with mean df and variance 2*df. The familiar sum of squared independent standard normals describes integer df; positive fractional df is defined through the gamma distribution instead. Do not round0.5 to 0 before calling the function.
Complete worksheet setup
Create ChiSquareControls. Put degrees of freedom 4 in B2. In D2 enter =RANDCHISQ($B$2). The result is a changing random variate, not a fixed 4.
In F2 enter =B2, in F3 =2*B2, and in F4 =SQRT(F3). The independent ideal mean, variance and standard deviation are 4, 8, and approximately 2.82842712475. These theoretical summaries must not be described as exact statistics of the next few draws.
Explicit contract and theory controls
The following table distinguishes source-derived constants/errors from ideal population summaries:
| Supplied input or control | Independent reference result |
|---|---|
| RANDCHISQ(0): source constant | 0 |
| RANDCHISQ(-1): source error | #NUM! |
| df=0.5: ideal mean / variance | 0.5 / 1 |
| df=1: ideal mean / variance | 1 / 2 |
| df=2: ideal mean / variance | 2 / 4 |
| df=4: ideal mean / variance | 4 / 8 |
In particular, the 0.5 case has ideal mean 0.5 and variance 1. It is valid without being a half-observation version of a finite sum of squared standard normals. The gamma definition handles that extension.
Advanced: inspect a squared-normal construction
As a deterministic algebra control only, put -1,0,1 and2 in A7:A10. In B7 use =A7^2 and fill down. The squares are 1, 0, 1 and 4, summing to 6.
If four genuinely independent standard-normal variates were used instead, their squared sum would have an ideal chi-square distribution with df 4. The supplied four numbers are not such a sample and do not establish that RANDCHISQ will return6. The actual Gnumeric helper uses gamma generation, not this four-cell construction.
Do not square four references to the same random cell and call the result chi-square4. That would be 4 times one squared variate, with a different distribution and dependence structure.
Advanced: an exact df 2 probability check
For df 2, the ideal chi-square distribution is exponential with scale 2. Its cumulative probability at x≥0 is 1-EXP(-x/2). At x 2 this is approximately 0.632120558829; at x 6 it is approximately 0.950212931632.
The ideal median is =2*LN(2), approximately 1.38629436112, which is less than the mean 2. Thus neither a median nor a typical individual result should be confused with the df parameter.
These formulas are fixed theoretical checks, not native random output. They provide a reproducible way to explain why a positively skewed distribution’s mean and median differ.
Advanced: independent sums and averages
For independent ideal chi-square variables with df 2 and df 3, their sum has df 5, mean 5 and variance 10. This follows from adding gamma shapes with the common scale 2. Independence is part of the statement; it cannot be established merely by writing a SUM formula.
For 100 independent df 4 draws, the ideal average has mean 4 and standard deviation =SQRT(8/100), approximately 0.282842712475. Averaging 100 references to one random value would instead reproduce that value and leave its standard deviation approximately 2.82842712475.
No simulation or convergence test was run here. These arithmetic controls help diagnose the difference between repeated references and a genuinely specified independent model.
Zero and negative degrees of freedom
=RANDCHISQ(0) reaches the gamma helper’s zero-shape return and gives 0 without requesting a gamma draw. =RANDCHISQ(-1) yields #NUM!. Very small positive df is not the same as0, and extreme parameters can produce floating-point limits; those limits are not characterized by these ordinary-domain controls.
Working with a changing result
The function is registered as volatile. A recalculation can replace its result; neither a copied screenshot nor an earlier value is a promised next draw. There is no seed argument in this function’s worksheet signature. Exact recalculation triggers, shared-generator sequencing and saved-file replay were not tested.
The controls below separate a changing random formula from deterministic arithmetic. The supplied driver values are teaching inputs, not values captured from Gnumeric’s generator. Population summaries describe the ideal continuous distribution and are not empirical certifications of the finite-resolution implementation.
Troubleshooting and verification limits
Use explicit finite numeric inputs for these controls. Text parsing, blank-cell coercion, locale-specific separators and array broadcasting are outside the verified examples. The numeric result constructor turns non-finite arithmetic into #NUM!; very large parameters or extreme transformed values can therefore fail even when the mathematical distribution is defined.
The underlying unit generator has finite resolution. Endpoint exclusions, rounding, overflow and underflow mean a theoretical continuous distribution is not a literal list of every machine output. No random samples, native worksheet execution, distribution-quality test, GUI operation or cross-application file transfer was performed for this guide. The executable checks verify deterministic transformations and mathematical reference values only.