Simulating the bus paradox

199 Views Asked by At

How can I simulate this Poisson process ?

We model the instants of arrival of a bus at a given stop with the Poisson process of intensity $\lambda$. And an instant T at which an individual reaches this stop. We want to calculate the average time between the previous bus, and the one that the individual will take.

1

There are 1 best solutions below

1
On BEST ANSWER

We know that the cumulative probability distribution function (cdf) for a Poisson process is given by $F(t)=1-e^{-\lambda t}$.

Get a random number generated between 0 and 1 - let this be $P$.

Then $P=1-e^{-\lambda t}$

$e^{-\lambda t}=1-P$

$-\lambda t=\ln (1-P)$

$t=-\frac{\ln (1-P)}{\lambda }$

This value $t$ is the time until the next bus arrives.

Repeat.

Start your simulation at t=0. No buses have yet arrived.

Generate your first random number $P_1$ and find $t_1=-\frac{\ln (1-P)}{\lambda }$.

Generate your second random number $P_2$ and find $t_2=-\frac{\ln (1-P)}{\lambda }+t_1$.

Continue generating your random numbers $P_i$ and find $t_i=-\frac{\ln (1-P_i)}{\lambda }+t_{i-1}$.

From what you say, you have a fixed time $T$ in mind at which the person will arrive.

Continue until $t_n > T$. The waiting time is $T-t_n$.

Run the simulation again to find a large number of waiting times and find their means.

Alternatively you could choose for the passenger to arrive at a random point. In my simulation of this, I let 1000 buses arrive. I stored this set of arrival times. I then picked at random an arrival time for a passenger using a random number generator to give $T$ such that $0<T<t_{1000}$. I then worked out the waiting time.

This was easier to simulate because I only had to create one list of bus arrivals, but I can see that you might not believe the outcome of this.