←back to thread

219 points skadamat | 1 comments | | HN request time: 0s | source
Show context
wodenokoto ◴[] No.41306786[source]
Why does he times tau by N when calculating the bus arrival times in the beginning?
replies(1): >>41306945 #
1. rhymer ◴[] No.41306945[source]
If the bus arrives on time, the arrival time would be [tau, 2 * tau, ..., N * tau].

One way to simulate "random" arrival time is to draw uniform points in the interval [0, N * tau].

It turns out the inter-arrival time generated this way is approximately exponential:

1. the difference of consecutive ordered uniformly distribution random variables follows a Beta(1, N) distribution [1].

2. As N goes to infinity, N * Beta(1, N) converges to Exponential(1) [2].

3. Since we scale the rand() by N * tau, the inter arrival time will follow an Exponential(1 / tau) distribution (as N goes to infinity), which has an expected value of tau [3].

Edit: I just realized that the author did mention this simulation is only an approximation in the side note.

[1] https://en.wikipedia.org/wiki/Order_statistic#The_joint_dist...

[2] https://en.wikipedia.org/wiki/Beta_distribution#Special_and_...

[3] https://en.wikipedia.org/wiki/Exponential_distribution#Relat...