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?
From the model’s saved run
The draw by colour
Without replacement. Expected = balls taken × the colour's share of the bag.
| Colour | In the bag | Expected | Mean drawn | 10th pct | 90th pct |
|---|---|---|---|---|---|
| Red | 10 | 3.0 | 2.99 | 1 | 5 |
| White | 15 | 4.5 | 4.50 | 2 | 7 |
| Blue | 20 | 6.0 | 6.02 | 4 | 8 |
| Green | 25 | 7.5 | 7.48 | 5 | 10 |
| Yellow | 30 | 9.0 | 9.01 | 6 | 12 |
S-curve (cumulative probability) of Without replacement, With replacement from the saved simulation.
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.
Inputs sheet
The number of balls of each colour in the bag, and how many you take out.
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.
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
Find similar models
- Product
- Type
- Application
- Uses
The results in detail
The spread: without and with replacement
Standard deviation of each count, exact and simulated.
| Colour | Without, exact | Without, simulated | With, exact | With, simulated |
|---|---|---|---|---|
| Red | 1.38 | 1.37 | 1.64 | 1.64 |
| White | 1.64 | 1.65 | 1.96 | 1.95 |
| Blue | 1.84 | 1.84 | 2.19 | 2.20 |
| Green | 1.99 | 1.99 | 2.37 | 2.40 |
| Yellow | 2.11 | 2.10 | 2.51 | 2.52 |
The chance of some outcomes
Simulated, and exact where Excel has the formula (HYPGEOM.DIST without replacement, BINOM.DIST with).
S-curve (cumulative probability) of Without replacement, With replacement from the saved simulation.
| Outcome | Without, simulated | Without, exact | With, simulated | With, exact |
|---|---|---|---|---|
| At least one ball of every colour | 97.8% | – | 94.7% | – |
| No red ball | 1.9% | 2.3% | 4.6% | 4.2% |
| 5 or more red balls | 13.5% | 13.8% | 16.9% | 17.5% |
| 12 or more yellow balls | 11.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.
| Assumption | Unit | Value |
|---|---|---|
| Red balls in the bagThe original example's bag: 100 balls | balls | 10 |
| White balls in the bag | balls | 15 |
| Blue balls in the bag | balls | 20 |
| Green balls in the bag | balls | 25 |
| Yellow balls in the bag | balls | 30 |
The draw 1 input
How many balls you take out, without putting any back.
| Assumption | Unit | Value |
|---|---|---|
| Balls taken outMust not be larger than the bag (checked) | balls | 30 |
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
- Set the bag's contents and the sample size on the Inputs sheet (the sample cannot be larger than the bag).
- Run a simulation from the ModelRisk ribbon (10,000 samples with a fixed seed are set).
- 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.
Download the workbook and run it yourself. It opens in Excel with ModelRisk. The free trial runs every example model.
Related example models
- ModelRisk★★★★★Correlation Through a Common Factor (Look-up Table)How much later does a project finish when bad weather hits every activity at once?One shared random factor and a look-up table make six durations move together, without a correlation matrix.
- ModelRisk★★★★★Envelope Correlation: Interest and Mortgage RatesHow do you make one variable follow another when you only know its range at a few points?Correlating two variables from expert ranges: the second's range follows the first.
- ModelRisk★★★★★Event Counts over Time: Poisson and PólyaHow uncertain is next year's total of house calls?The same expected counts with three amounts of randomness: Poisson, and two ways of adding Pólya's extra variation.
An illustrative example: the figures are invented for teaching and do not describe a real company, project or asset. Last updated 9 October 2026.