Your first simulationLesson 01 of 76 · 6 min
Will the room be full?
Estimate the probability that attendance exceeds a room’s capacity.
New to probability? Try optional lesson 0.
An organiser has invited 150 people to a room with 110 seats. Suppose each guest has a 0.72 (72%) chance of attending. Assume independent attendance: learning one guest’s decision does not change another guest’s chance. This is an explicit teaching model, not a measured attendance rate. A simulation generates possible events under those assumptions.
One trial is one complete event: draw who attends, count them and compare the count with the seats. Repeating produces a distribution, the possible counts and how often they occur. A boolean is a True/False decision; NumPy counts True as 1 and False as 0. Averaging the overflow decisions therefore gives the fraction of whole events with attendance greater than 110.
NumPy is a Python library for array calculations. Its binomial generator counts yes/no successes among a fixed number of opportunities. Here those opportunities are the individual guests; one complete Monte Carlo trial is still the whole event. The arguments are invitation count, guest attendance chance and number of simulated events. The seed makes this particular run repeatable. Your estimate describes the model; checking whether its assumptions describe real guests is a separate task.
In the reference, X is attendance, c is the seat count, k counts overflow events and n counts complete simulated events. The hat on P marks an estimated probability.
Will raising the seat count change attendance, or only the overflow condition?
Write a prediction (optional)
Seeded teaching simulation
Select Run Python below with the code unchanged.
A saved draft is open. To run the published example, open Tools and select Restore example. Recover draft brings your code back.
Execution error
Technical error details
Your result
Published example output
This result comes from the original Python. Your runs appear above. Build environment ↗
Simulated events: 10000 Estimated P(attendance > seats): 0.3211 Mean attendance: 107.98
Read the first result
Find Simulated events and Estimated P(attendance > seats). The first number counts whole events. The second is the fraction whose attendance is strictly above the seat limit. On the plot, the dashed line marks that limit. Exactly 110 guests fit in 110 seats.
Try an edit
Replace 150, 0.72, 110 with 150, 0.72, 120. Select Run Python again. Compare Mean attendance and Estimated P(attendance > seats) with the first run. On the plot, find the new seat boundary. Which result changes when the same attendance draws are judged against more seats?
Scope. Independent attendance with a known common probability is assumed. Shared weather or invitation groups could change the distribution.
Try a fresh case
You want the probability of at least 110 attendees. Which condition matches?
Need a hint?
Hint 1
Write the smallest count that qualifies.
Hint 2
Decide whether exactly 110 belongs in the event.