This is the second of FiveThirtyEight’s weekly logic problems. Hopefully I’ll be able to continue keeping up with them
The Problem
—
“You arrive at the beautiful Three Geysers National Park. You read a placard explaining that the three eponymous geysers — creatively named A, B and C — erupt at intervals of precisely two hours, four hours and six hours, respectively. However, you just got there, so you have no idea how the three eruptions are staggered. Assuming they each started erupting at some independently random point in history, what are the probabilities that A, B and C, respectively, will be the first to erupt after your arrival?”
—
The Process
—
Fricken conditional probability. This problem was really an exercise in starting small and working my way up. I started with two geysers going off on two hour periods, two going off on 2/4 hour periods, three on a 2/2/2 cycle and finally the 2/4/6 that the problem called for.
—
The Solution
—
Well the resulting equation looks like this:
This is the sum of the probability that the geyser goes off before either of the other two have, represented by the (1-t/t_0)’s. Integrate this over one period, 2, because it is the full period of A. Doing this for each gives the following probabilities:
p(A): 23/36, p(B): 8/36, p(C): 5/36
This thankfully sums to one and was quickly tested in 10,000 MATLAB simulations. The code for that is below:
clear all, clc, close all viewings = zeros(3,1); for i = 0:10000000 a_start = floor(rand(1,1)*2*60); b_start = floor(rand(1,1)*4*60); c_start = floor(rand(1,1)*6*60); person_arrival = floor(rand(1,1)*10000); eruption_viewing = 0; while eruption_viewing == 0 if mod(person_arrival,120) == a_start eruption_viewing = 1; viewings(1,1) = viewings(1,1) + 1; end if mod(person_arrival,240) == b_start eruption_viewing = 1; viewings(2,1) = viewings(2,1) + 1; end if mod(person_arrival,360) == c_start eruption_viewing = 1; viewings(3,1) = viewings(3,1) + 1; end person_arrival = person_arrival+1; end end viewings = viewings./i expected = [23/36;8/36;5/36] differences = viewings - expected
The differences in the two was less than 1% in total. Cool!