Let’s get back to the motivating question: suppose that when I arrive at the platform I see 10 people waiting. How long should I expect to wait until the next train arrives?
As always, let’s start with the easiest version of the problem and
work our way up. Suppose we are given the actual distribution of z
, and we know that the passenger arrival rate,
λ, is 2 passengers per minute.
In that case we can:
Use the distribution of z
to
compute the prior distribution of zp
, the time between trains as seen by a
passenger.
Then we can use the number of passengers to estimate the
distribution of x
, the elapsed time
since the last train.
Finally, we use the relation y = zp -
x
to get the distribution of y
.
The first step is to create a WaitTimeCalculator
that encapsulates the
distributions of zp
, x
, and y
,
prior to taking into account the number of passengers.
wtc = WaitTimeCalculator(pmf_z)
pmf_z
is the given
distribution of gap times.
The next step is to make an ElapsedTimeEstimator
(defined below), which
encapsulates the posterior distribution of x
and the predictive distribution of y
.
ete = ElapsedTimeEstimator(wtc, lam=2.0/60, num_passengers=15)
The parameters are the WaitTimeCalculator
, the passenger arrival rate,
lam
(expressed in passengers per
second), and the observed number of passengers, let’s say 15.
Here is the definition of ElapsedTimeEstimator
:
class ElapsedTimeEstimator(object): def __init__(self, wtc, lam, num_passengers): self.prior_x = Elapsed(wtc.pmf_x) ...
No credit card required