Suppose that you have a Battenburg cake, which is 1 unit long.
You then:
- place two candles at random positions along the length
- randomly cut the cake across the length
What is the probability that the knife cuts between the two candles?
When the candles and knife are uniformly distributed the probability that the knife is between both candles is
Full working is provided in the main notebook.
A live version of the notebook can be launched on mybinder.org.
A prototype library is provided to calculate probabilities under different probability distributions.
This example uses a Beta(2,2) distribution for the knife and uniform distribution for both candles.
from utils import BetaBD, UniformBD, calculate_prob
from functools import partial
Beta22 = partial(BetaBD, a=2, b=2)
p = calculate_prob(Beta22, UniformBD, UniformBD)
print(p)
0.45
WARNING: I advise against using Piecewise defined functions for this as it will likely cause sympy's integration system to fail.
I originally saw this problem presented by Ben Sparks on Numberphile https://www.youtube.com/watch?v=FkVe8qrT0LA.
This problems seems to have been around before hand though as I found it on New Scientist https://www.newscientist.com/article/mg24232361-100-puzzle-09-the-cake-and-the-candles/