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.

Overflow is an event, not an average
87.597.51081181280216432649865Simulated eventsAttendees per event
87.597.51081181280216432649865Simulated eventsAttendees per event
P^(X>c)=k/n\widehat P(X>c)=k/n
Reference illustration. Seeded published reference: 10,000 events with 150 independent invitations at chance 0.72. Highlighted bars count attendance strictly above 110; exactly that many guests still fit. This is an assumed attendance model, not measured turnout. Here k counts overflow events and n counts all simulated events.

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.

Tools
About Python ↗

The code is editable. Press Ctrl+Enter or ⌘+Enter to run Python from the editor.

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
Plot generated from the published Python during the build. Refer to its labelled axes and the text output.
Open full-size figure ↗

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?

Back to the Python editor

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?

Choose an answer
Need a hint?
Hint 1

Write the smallest count that qualifies.

Hint 2

Decide whether exactly 110 belongs in the event.

Your notes