FiveThirtyEight has a new puzzle feature called The Riddler. This week they posted their second puzzle, which involves probability:
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?
Responses were due last night at midnight, so I hope I’m not spoiling anything by sharing mine.
When you arrive at the park, the first eruption of geyser A is likely to occur at any time within the next two hours with a uniform probability. Denoting the number of hours until the first eruption of the geyser as “A”, A ~ Uniform(0, 2). Similarly, B ~ Uniform(0, 4) and C ~ Uniform(0, 6).
To compute the probability of geyser A erupting first, separately consider the cases where geysers B and C do and do not erupt within the first two hours of waiting.
Using Bayes Theorem:
Assuming independence of the geysers:
Considering the case here, in which all three geysers erupt in the first two hours, the probability of any geyser erupting first is 1/3. The probability of geysers B and C erupting in the first two hours is easy to calculate.
Using similar logic:
These disjoint events partition the sample space, so the law of total probability dictates:
Do the same thing to calculate the probability of geyser B erupting before the others:
Note that when geyser B does not erupt within the first two hours, another geyser is guaranteed to erupt before it:
And geyser C is similar:
It never hurts to check results with a simulation. After all, math is hard and programming is easy.
library(dplyr) library(ggplot2) numSamples <- 1e6 # Generate random wait times for each geyser's next eruption geysers <- data_frame(A = runif(numSamples, 0, 2), B = runif(numSamples, 0, 4), C = runif(numSamples, 0, 6)) geyserNames <- colnames(geysers) # Identify the geyser with the smallest time-to eruption geysers <- geysers %>% mutate(first_geyser = geyserNames[max.col(-geysers[, geyserNames])]) # Plot the results geysers %>% ggplot(aes(x = first_geyser)) + geom_bar()
# Count observations and estimate probabilities geysers %>% count(first_geyser) %>% mutate(prob_first = n / numSamples)
## Source: local data frame [3 x 3] ## ## first_geyser n prob_first ## 1 A 640093 0.640093 ## 2 B 221439 0.221439 ## 3 C 138468 0.138468