A certain 2-year-old is eating his favorite snack: an apple. But he eats it in a very particular way. When he first receives the apple, and every minute thereafter, he rotates the apple to a random position and then looks down. If there’s any skin of the apple left in the spot where he plans to take a bite, then he will indeed take that bite. But if there’s no skin there (i.e., he’s already taken bites at that spot), he won’t take a bite and will rotate the apple for another minute.
Once he has bitten off all the skin of the apple, he’s done eating.
Suppose the apple is a sphere with a radius of 4 centimeters, and that each bite of the apple is a circle of the sphere whose radius, as measured along the apple’s curved surface, is 1 centimeter. On average, how many minutes will it take this 2-year-old to eat the apple?
First, a personal note. This problem was super challenging, and it took me much longer than I wanted it to. I could not successfully simulate this to save my life, so a huge shout out to Jason Ash (@ashjasont on Twitter) and Emma Knight (@rp2knight on Twitter) for their simulations. Kudos!
Okay, now on to the good stuff. With a sphere of radius 4 cm, the circumference of the sphere is \(2\pi r = 2\pi(4) = 8\pi\). For a arc radius of 1 cm, this will give an angular radius of \(\alpha = \frac{1}{8\pi} * 2\pi = 0.25\). This is about \(14.324^\circ\) for those of you that prefer degrees over radians.
The question asks for how many minutes the toddler will take, not how many bites he will take, which simplifies the problem a little. Using this, we can assume that every minutes he’ll take a bite (even the vacuous bite of nothing).
The article “Random circles on a sphere” by P. A. P. Moran and S. Fazekas de St. Groth that appeared in Biometrika in 1962 was very helpful in solving this problem. What I found very timely about this article was in the first sentence of the second paragraph: “This problem arises in practice in the study of the theroy of the manner in which antibodies prevent virus particles from attacking cells.”
It took quite a while to digest the article, but the punchline is as follows. For a sphere on which N circles of angular radius \(\alpha\) are placed uniformly on the surface of the sphere at random, the probability that the sphere is covered, \(P\), is given as \[ P = \text{exp}\left\{-\frac{\pi^2}{2}(m_2m_1^{-2} - 1)^{-1}\right\}, \] where \(m_1 = \left(\frac12 + \frac12 \cos(\alpha)\right)^N\), and \(\text{exp}\left\{x\right\} = e^x\), and \(m_2\) is a step function. It is defined as \[ m_2 = \frac12 \int_0^\pi G(\phi)^N\sin(\phi)\,\,d\phi, \] where \[ G(\phi) = \left[1-\frac{1}{\pi}\left(\cos^{-1}\left(\frac{\tan(\phi/2)}{\tan(\alpha)}\right)\right)\right]\cos(\alpha)+\frac{1}{\pi}\cos^{-1}\left(\frac{\sin(\phi/2)}{\sin(\alpha)}\right), \,\,\, \text{ on } 0\leq \phi \leq 2\alpha, \] and \(G(\phi) = cos(\alpha)\) on \(2\alpha\leq \phi \leq \pi\).
Quite complicated to wrap your head around, but not to difficult to plug into R. Let’s get to it.
## Let's first define the m1 function.
# Inputs include N, the number of circles on the sphere
# and a, the angular radius of our circles with default value set to 0.25
m1 <- function(N, a = 0.25){
return((0.5+0.5*cos(a))^N)
}
## Next, I'll build the function G. It will only be necessary to build it
## specifically for the interval 0 to 2*alpha
# Inputs include an angle phi that will range from 0 to 2*alpha, and
# a, the angular radius of our circles with default value set to 0.25
G <- function(phi,a=0.25){
return((1-1/pi*(acos(tan(phi/2)/tan(a))))*cos(a)+1/pi*acos(sin(phi/2)/sin(a)))
}
## Next, we will build the m2 function which will require numerical integration.
# Inputs include N, the number of circles on the sphere
# and a, the angular radius of our circles with default value set to 0.25
m2 <- function(N,a = 0.25){
# From 0 to 2*alpha we want a specific integrand
m2_1_int <- function(phi){
return(G(phi,a)^N*sin(phi))
}
# This will get the numerical result from integrating from 0 to 2*alpha
m2_1 <- integrate(m2_1_int, 0, 2*a)$value
# From 2*alpha to pi, we want a simpler integrand
m2_2<- integrate(function(phi) (cos(a))^N*sin(phi), 2*a, pi)$value
## Finally, send half the sum as the definition of m2 suggests.
return(0.5*(m2_1+m2_2))
}
We now have the tools to calculate the probability that N circles that have angular radius \(\alpha\) cover the sphere. Using the formula given in the paper, we get
## This represents the probability N circles of angular radius a with default
## value 0.25 will cover the sphere.
P_Cover <- function(N, a = 0.25){
if(N == 0 | N==1){return(0)}
else return(exp(-pi^2/2*((m2(N,a))*m1(N,a)^-2-1)^-1))
}
## Testing some different values
P_Cover(1)
## [1] 0
P_Cover(76)
## [1] 0
P_Cover(77)
## [1] 4.940656e-323
P_Cover(568)
## [1] 0.4991809
P_Cover(569)
## [1] 0.5034443
According to this, 76 bites will not be enough, but 77 may be enough as long as it was done perfectly. It also suggests that 568 bites seems to be about the median number of bites needed.
Let \(X\) be a random variable defined as the number of circles needed in order to cover the sphere. Then we can see that the cdf \(F(n) = P(X\leq n)\) is the function that we have defined above. Using a nice result from probability, we have that \[ E(X) = \sum_{n=0}^{\infty} (1-F(n)). \]
Let’s see what we get.
bites <- 0:1500
sum(sapply(bites, function(b) 1-P_Cover(b)))
## [1] 584.2331
bites <- 0:2000
sum(sapply(bites, function(b) 1-P_Cover(b)))
## [1] 584.2332
E <- function(a=0.25){
k <- 50
while(P_Cover(k,a)<1){
k <- k+10
}
bites <- 0:k
return(sum(sapply(bites, function(b) 1-P_Cover(b, a))))
}
E(0.25)
## [1] 584.2332
E(53.43*pi/180) ## The angle from the paper
## [1] 27.02326
Our answer seems to be right around 584.2332 bites. Since the median is 568, this must be a positively skewed distribution. Let’s have a look.
Now, let’s look at something a little more interesting. If we alter the angular radius of the bite, what is the expected number of minutes it will take the toddler to eat?