Sampling from Several Groups: Hypergeometric | Vose Software

ModelRisk example · General techniques

Sampling from a Population of Several Groups

Take 30 balls from a bag of 100 in five colours: how many of each will you get?

  • Complexity: ★★★★★
  • Free Excel workbook (GU-18)
  • Needs ModelRisk: free trial

From the model’s saved run

The draw by colour

Without replacement. Expected = balls taken × the colour's share of the bag.

ColourIn the bagExpectedMean drawn10th pct90th pct
Red103.02.9915
White154.54.5027
Blue206.06.0248
Green257.57.48510
Yellow309.09.01612
Red balls in the draw

The business question

A bag holds 100 coloured balls: 10 red, 15 white, 20 blue, 25 green and 30 yellow. You take out 30 without looking and without putting any back. The five counts are linked: they always add up to 30, and every ball of one colour taken leaves less room for the others. VoseMultiHypergeo draws all five counts at once.

The model also draws the same 30 with replacement (VoseMultinomial), to show how much taking balls out narrows the spread.

Who it is for
Anyone drawing a sample without replacement from a population split into groups: audit samples across account types, inspections across production lines, survey samples across regions, captures across species.
Main outputs
The number of each colour in the draw: expected, mean and 10th / 90th percentiles · the spread with and without replacement · the chance that every colour is drawn, that no red is drawn, of 5 or more red and of 12 or more yellow.

How the model works

Three sheets after this one, read from left to right. Each one feeds the next.

  1. Inputs sheet

    The number of balls of each colour in the bag, and how many you take out.

  2. Draw sheet

    VoseMultiHypergeo draws the five counts without replacement, as one array; VoseMultinomial draws them with replacement. Beside them: each colour's share of the bag, its expected count and the exact standard deviation both ways.

  3. Results sheet

    Each colour's count (expected, simulated mean, 10th and 90th percentiles), the spread with and without replacement, and the chance of a few outcomes both ways.

ModelRisk techniques

  • Without replacement VoseMultiHypergeo
  • With replacement VoseMultinomial
  • Finite-population correction
  • Probabilities VoseSimProbability

Find similar models

Product

The results in detail

The spread: without and with replacement

Standard deviation of each count, exact and simulated.

ColourWithout, exactWithout, simulatedWith, exactWith, simulated
Red1.381.371.641.64
White1.641.651.961.95
Blue1.841.842.192.20
Green1.991.992.372.40
Yellow2.112.102.512.52

The chance of some outcomes

Simulated, and exact where Excel has the formula (HYPGEOM.DIST without replacement, BINOM.DIST with).

Yellow balls in the draw
OutcomeWithout, simulatedWithout, exactWith, simulatedWith, exact
At least one ball of every colour97.8%–94.7%–
No red ball1.9%2.3%4.6%4.2%
5 or more red balls13.5%13.8%16.9%17.5%
12 or more yellow balls11.6%11.8%16.3%15.9%

How to read these results

  • On average the draw mirrors the bag: 30 balls are 30% of it, so expect 3 red, 4.5 white, 6 blue, 7.5 green and 9 yellow.
  • The five counts are linked: they always add up to 30, so a draw with many yellow has fewer of the others. VoseMultiHypergeo draws them together; five separate hypergeometric draws would not add up to 30.
  • Not putting balls back narrows the spread: every standard deviation is 0.84 times the with-replacement one (√(70/99), the finite-population correction). The larger the draw is next to the bag, the bigger the effect. A draw of 1% of a large population hardly feels it.
  • So extremes are rarer without replacement: no red ball has an exact 2.3% chance against 4.2% with replacement, and 12 or more yellow 12% against 16%. The simulated figures differ from the exact ones only by sampling error.

See it move. Open the workbook, change an input on the Inputs sheet and run the simulation: every table and chart on this page updates in Excel.

Inputs and assumptions

Every assumption in the model, with its uncertainty and where it comes from. The figures are illustrative.

The bag 5 inputs

The number of balls of each colour.

AssumptionUnitValue
Red balls in the bagThe original example's bag: 100 ballsballs10
White balls in the bagballs15
Blue balls in the bagballs20
Green balls in the bagballs25
Yellow balls in the bagballs30
The draw 1 input

How many balls you take out, without putting any back.

AssumptionUnitValue
Balls taken outMust not be larger than the bag (checked)balls30

Units and conventions

Without replacement
A ball taken out is not put back: the model's draw (VoseMultiHypergeo).
With replacement
Every ball is put back before the next is taken: the comparison (VoseMultinomial).

Key assumptions and limitations

Random draw
Every ball still in the bag is equally likely to be taken next.
Data
The bag and the draw are those of ModelRisk's earlier Multivariate Hypergeometric example. Its text called the second colour white and its table purple: white is used here.

How to use it

  1. Set the bag's contents and the sample size on the Inputs sheet (the sample cannot be larger than the bag).
  2. Run a simulation from the ModelRisk ribbon (10,000 samples with a fixed seed are set).
  3. For your own problem, replace the colours by your groups: account types, production lines, regions.

ModelRisk functions used

VoseMultiHypergeo
The number of each colour in a draw without replacement, as one array.
VoseMultinomial
The same draw with replacement.
VoseOutput
The counts and the every-colour indicator, recorded at every sample.
VoseSimMean, VoseSimStdev, VoseSimPercentile, VoseSimProbability
Statistics of the simulation.

Further reading

  • Monte Carlo simulation explained (Vose guide)
  • Vose, D. (2008). Risk Analysis: A Quantitative Guide, 3rd edition. Wiley: the hypergeometric process and the multivariate hypergeometric distribution.