Contact

RANDHYPERG Function (Gnumeric)

Statistical Intermediate Gnumeric Gnumeric 1.1.6

RANDHYPERG(n 1,n 2,t) counts type 1 objects in a sample drawn without replacement. Its three numeric arguments are floored before validation and quantile generation.

Verification status: See the evidence and test scope described in this guide. How formula examples are checked

Quick answer: RANDHYPERG(n 1,n 2,t) counts type 1 objects in a sample drawn without replacement. Its three numeric arguments are floored before validation and quantile generation.

Syntax

=RANDHYPERG(n 1,n 2,t)

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.

Parameters and source contract

All three arguments are required. n 1 is the number of type 1 objects, n 2 the number of type 2 objects, and t the total number selected. The callback floors each numeric argument, then the helper requires nonnegative counts and t≤n 1+n 2.

The output counts type 1 selections. For valid integer inputs its ideal range is MAX(0,t-n 2) through MIN(t,n 1), inclusive. This is a finite-population model without replacement, not a fixed-probability binomial model for independent trials.

The helper sends a unit driver to the hypergeometric quantile routine, whose search is bounded by those same lower and upper counts. It does not explicitly shuffle a list of objects in the worksheet.

Complete worksheet setup

Create HypergeometricControls. Put type 1 count 4 in B2, type 2 count 6 in B3, and sample size 3 in B4. In D2 enter =RANDHYPERG($B$2,$B$3,$B$4). The result can be 0,1,2 or 3 and changes; no fixed draw is supplied.

The ideal mean is =B4*B2/(B2+B3), or 1.2. The variance is =B4*(B2/(B2+B3))*(B3/(B2+B3))*((B2+B3-B4)/(B2+B3-1)), or 0.56. This variance formula assumes total population greater than 1.

Reproducible probability table

Put counts 0,1,2 and 3 in A7:A10. In B7 enter =COMBIN($B$2,A7)*COMBIN($B$3,$B$4-A7)/COMBIN($B$2+$B$3,$B$4) and fill down. The independent probabilities are:

Supplied input or fixed count Independent reference result
k=0 1/6
k=1 1/2
k=2 3/10
k=3 1/30

These exact fractions sum to 1. Their probability-weighted mean is 1.2 and variance 0.56. They describe the model’s complete support for this dataset, not a list of four randomly generated observations.

Advanced: compare with replacement

A binomial model with three independent trials and success probability 0.4 has the same mean 1.2 but variance 0.72. Without replacement, the finite-population factor (10-3)/(10-1)=7/9 reduces that variance to 0.56.

The difference comes from dependence introduced by drawing without replacement. Do not substitute a binomial generator merely because its mean agrees. When the entire population is sampled, the type 1 count is exactly n 1.

Advanced: complementary type counts

For a realized type 1 count D2, the corresponding type 2 count is =B4-D2. Its ideal mean is 1.8. This direct complement uses the same sample.

A separate =RANDHYPERG(6,4,3) call describes the swapped population, but does not promise a complementary draw adding to 3 with D2. The distributional symmetry and same-sample identity are different statements.

Advanced: inspect flooring before validation

The callback maps arguments 4.9,6.9,3.9 to 4,6,3 before calling the helper. They therefore specify the same source-model distribution as the original integer setup, without promising the same sequence of random outputs.

A negative fractional count such as-0.1 floors to-1 and is invalid; it is not truncated to zero. A draw count 10.9 with populations 4 and 6 floors to 10 and is accepted as a full-population sample, giving 4. In contrast, draw count 11 is too large and gives #NUM!.

Use explicit integer counts in normal work so these conversion rules do not silently change the intended population.

Degenerate and error controls

=RANDHYPERG(4,6,0) gives 0. =RANDHYPERG(4,6,10) gives 4. With all objects of type 1, =RANDHYPERG(4,0,3) gives 3; with no type 1 objects, =RANDHYPERG(0,6,3) gives 0. These are support-collapse cases, not evidence that the helper skips its unit-generator call.

Negative floored counts or a floored sample exceeding the total population produce #NUM!. Extremely large counts and native quantile-search behavior were not empirically certified; the verified examples use small exact populations.

Recalculation and verification limits

The plugin marks this function volatile. Recalculation can replace a result, and the worksheet signature has no seed argument. Exact GUI triggers and saved-file replay were not tested. Separate calls do not promise matched internal drivers, while repeated references to one random cell do not constitute independent observations.

The controls here are independent mathematical or source-branch expectations, not generated samples. Ideal probability distributions are distinct from the finite-resolution implementation. Rounding, underflow, overflow and non-finite intermediates can affect extreme inputs; non-finite numeric results become #NUM!. No native application, compiled Gnumeric helper, random generator, empirical distribution-quality test or file-transfer test was executed. Use explicit finite numeric inputs; text and blank coercion are not certified by these controls.