This software was largely created by AI Vibe Coding
Created by YouMinds
The inspection paradox describes why a randomly arriving passenger tends to experience longer‑than‑average
waiting times, even when buses have a fixed average spacing. Because long gaps occupy more of the timeline,
an arrival is more likely to fall inside one of these long intervals.
This interactive simulation of the inspection paradox uses a stream of buses moving across a timeline.
This simulation shows buses passing at a bus stop along a timeline with adjustable spacing variance. Each
arrival marks
where
a passenger appears and calculates the wait until the next bus. The charts visualize how large gaps dominate
the
average, making the typical wait time longer than the typical bus interval would suggest — the core of the
inspection
paradox.
Inspections counted: 0
- Last observed wait time: 0 seconds
Animation speed:
Bus Stop
Bus arrives every 0 seconds, thus estimated average wait time:
0 seconds.
Actually observed: 0 seconds
Deviation of bus intervals:
50%
- ( σ = 0 seconds )
Select the amount of deviation in the bus interval. 0% means all
buses arrive at the same time,
100% means a wide range of arrival times according to an exponential distribution.
The effect of the inspection paradox is more pronounced with higher variance, as longer gaps
become more
likely.
Increase
the deviation to see how the average observed wait time grows relative to the average bus spacing.
Here you can see the distribution of bus intervals.
The x-axis shows the time intervals between buses, and the y-axis shows how many times each interval
occurred.
As the variance increases, the distribution becomes more spread out, leading to longer gaps
and thus longer average wait times for passengers.
This chart compares the average observed wait time, the estimated average wait time based on bus
intervals, i.e. the actual average arrival time of buses. It illustrates how the inspection paradox
leads
to longer observed wait times than expected.
Press Inspect Now to simulate a passenger arriving at the bus stop and see
how the observed wait time compares to the estimated wait time.
Press Random Inspections to simulate multiple random arrivals
automatically and observe how the average wait time evolves over time.
What is the inspection paradox anyway?
The inspection paradox is a counterintuitive statistical phenomenon that appears in many real‑world systems,
especially those involving random arrivals — such as buses, trains, elevators, or even network packets.
Although vehicles may be scheduled with a certain average spacing, a randomly arriving passenger is more
likely to encounter longer gaps than shorter ones. In other words, the average person’s waiting time is
typically longer than the average interval between buses.
The inspection paradox occurs when
the average waiting time for an event, such as the arrival of a bus, is longer than the average time
between events. This paradox arises because longer intervals are more likely to be sampled when observing
events at random times, leading to a biased perception of the average waiting time.
What is the mathematical explanation?
The mathematical explanation of the inspection paradox can be understood through the concept of expected
value and the distribution of intervals between events. When events occur at random intervals, longer
intervals occupy more time on the timeline, making it more likely for a randomly arriving observer to
encounter one of these longer intervals.
If L is the true interval length and Lobs is the observed one and E is the expected value or the
average: then
$$ L_{obs} = \frac{E[L^2]}{E[L]} > E[L] $$
With variance σ² and mean μ:
$$ L_{obs} = \mu + \frac{\sigma^2}{\mu} $$
For an exponential distribution (
σ2 = μ2):
$$ L_{obs} = \mu + \frac{\mu^2}{\mu} = 2\mu $$
The expected waiting time is not μ/2, but:
$$ E[W] = \frac{L_{obs}}{2} = \frac{2\mu}{2} = \mu $$
The exponential distribution is a special case of the inspection paradox, where the observed average
interval is twice the mean interval, leading to an expected waiting time equal to the mean interval itself.
Queueing Systems and Exponential Distributions
The exponential distribution is used to model queueing systems, reliability analysis, and other areas where
random events occur over time. The inspection paradox serves as a reminder that our intuitive understanding
of averages can be misleading when dealing with random processes and distributions.
Queueing systems lead to exponential waiting times because the service times are often modeled as
exponentially distributed.
This can be explained by the memoryless property of the exponential distribution, which states that the
probability of an event occurring in the future is independent of how much time has already elapsed. In a
queueing system, this means that the expected waiting time for a customer does not depend on how long they
have already been waiting. As a result, the waiting times tend to follow an exponential distribution, which
is characterized by a constant hazard rate and a decreasing probability density function.
The distribution is a direct outcome of the rate at which events occur in a Poisson process, which is often
used to model random arrivals in queueing systems.
The Poisson process is a mathematical model that describes the occurrence of random events over time or
space. It is characterized by a constant average rate of events and the independence of events from one
another. The exponential distribution arises as the inter-arrival time distribution in a Poisson process,
making it a natural choice for modeling waiting times in queueing systems.
Mathematically, the Poisson process is defined by the following properties:
The number of events in non-overlapping intervals is independent.
The probability of a single event occurring in a small interval is proportional to the length of the
interval.
The probability of more than one event occurring in a small interval is negligible.
The exponential distribution is defined by its probability density function (PDF):
$$ f(t; \lambda) = \lambda e^{-\lambda t} \quad \text{for } t \geq 0 $$
where
λ
is the rate parameter, which is the reciprocal of the mean inter-arrival time.
How was it built
This software was created using Vibe Coding by a Large Language Model LLM / chatbot
and reworked in look & feel.
Some features had to be implemented manually and
corrections and improvements had to be made.
The following Vibe Coding prompts were used on Copilot:
"create a single page html page with javascript to simulate the inspection paradox. create a canvas
with a timeline where busses are moving from right to left. Add a slider that determinex the variance in
the bus distance. Add a button that simulates arrival at the bus stop and checks at which time between
two busses the arrival occurred. compute the total wait time and the average wait time."
"count the number of arrivals. Also draw a vertical line at the position where the arrival occured and
let these line float with the busses. The arrival should occur in the center of the canvas."
"add compute the total average distance of all buses. Also compute the real statistical variance. Draw
the distance value between the buses. Add a chart.js with the values."
"change the bus distance chart to a distribution chart. Add a chart with Average wait time and
Average bus distance"
"display all values in seconds. Make the Average Wait Time & Average Bus Distance a simple two bar
chart."
"How can I generate exponentially distributed random values using JavaScript?"
"How can I modify the JavaScript function for the exponential distribution so that an additional
parameter determines the variance?"
"I simply want a parameter that determines whether the distribution behaves like a log-distribution or
always yields the same single value—essentially compressing the distribution."