The First Ball Was Red: A Hypergeometric Whodunit
A small Bayesian network shows why learning that three draws contained two reds and one blue raises the probability that the first ball was…
The First Ball Was Red: A Hypergeometric Whodunit
A small Bayesian network shows why learning that three draws contained two reds and one blue raises the probability that the first ball was red from (6/11) to (2/3).

Gemini Plus image
Since Barry Leung didn’t mind my borrowing his first puzzle, I’m borrowing another one!

Note that this is sampling WITHOUT replacement. This means that each draw is dependent on the previous one. This dependence must be implemented with causal arrows:

Network with default generic uniform distributions

The empty CPT tables for each node
Notice that each table has more and more entries since the next depends on what happened in the previous ones. This means each equation becomes a bit more complicated to capture the increasing dependencies.
We need 3 equations:

Three equations reflects increasing depletion of balls
Once compiled, we have the tables filled in with the count.

The count will be automatically converted into probabilities by Netica
We now want to keep track of the number of Red balls and Blue balls drawn with two deterministic count nodes (in blue):

Network before compiling equations
We add two simple count equations (where Red = 0 and Blue = 1), and we have this complete set of equations:

The complete set of equations
Once compiled, we have this updated network:

The updated network with probability distributions for Red and Blue balls drawn
Notice that the probability of drawing 2 Red balls and 1 Blue ball is 45.5%
As a useful sanity check, let’s generate the two hypergeometric distributions with the built-in function in Netica:

This confirms that our network has generated the right distribution
All we now need to do is see our answer by instantiating the network (in green) and see the probability that the first ball drawn was red:

We enter the observation (in green) that 2 Red bals and 1 Blue ball were drawn
We answer that the probability the first ball drawn was red is 2/3.
Summarizing what we have done: The three draw nodes model the actual sequential process: first draw, second draw, third draw, with probabilities updated after each draw. The count nodes then summarize the sequence's results. As a check, the count distribution agrees with the built-in hypergeometric distribution, as expected when drawing 3 balls without replacement from a box containing 6 red and 5 blue balls.
Let’s change the sampling model slightly.
Different sampling model, same posterior answer.
Same problem, but we sample WITH replacement instead. What is the probability that the first draw was red?
We reuse the same network, but we can delete the arrows between each draw, since each is independent of the next.

The structure is almost the same but each draw is INDEPENDENT so we eliminate the arrows
The count distribution is now Binomial:

Binomial Distribution
Note that the expected value (the mean) is the same at 1.64 and 1.36, but that the Standard deviation is now 0.86 instead of 0.77. Notice also that the probability that 2 Red and 1 Blue balls are drawn is 40.6% instead of 45.5%.
Note that the equations are the same for each draw:
P (draw1 | ) =
select0 (draw1, 6, 5) // there are 6 Red balls and 5 Blue ones
P (draw2 | ) =
select0 ( draw2, 6, 5)
P (draw3 | ) =
select0 (draw3, 6, 5)
We can now enter our observation that a total of 2 Red and 1 Blue balls were drawn (but in unknown order).

Once again, the probability is the same at P(draw1 = red) = 2/3.

WITH or WITHOUT replacement makes no difference!
FINAL OBSERVATION
What was the probability of drawing 2 Red and 1 Blue WITH replacement versus WITHOUT replacement? Which Scenario was more likely? We saw that with replacement, the probability was 40.6%, but without replacement, it was slightly higher at 45.5%.
With replacement, each draw forgets the past. Without replacement, the box remembers. That memory changes the probability of seeing two reds and one blue. But once we are told that the three positions contain exactly two reds and one blue, symmetry takes over: two of the three positions are red, so the probability that the first position is red is still 2/3.
SOURCES & REFERENCES
메타데이터
- post_id
- 73f4ae53d015
- slug
- the-first-ball-was-red-a-hypergeometric-whodunit-73f4ae53d015
- url
- https://medium.com/@pbercker/the-first-ball-was-red-a-hypergeometric-whodunit-73f4ae53d015
- canonical_url
- https://medium.com/@pbercker/the-first-ball-was-red-a-hypergeometric-whodunit-73f4ae53d015
- author_url
- https://medium.com/@pbercker
- status
- ok
- fetched_at
- 2026-07-13 06:23:13