Last night around 1 a.m. I got up to go to the bathroom and as I was using the facilities a moth flew in the open window and and began to weave its helical path under the light. I beat a hasty retreat back to bed and lay there thinking how long it would take the moth, now flying randomly in the dark, to escape out of the window, making the bathroom safe again for humanity.
Suppose the probability that it flies across the bathroom and just happens to escape out the window is p, while the probability that it encounters a wall and has to randomly fly off in a different direction is q -- so p + q = 1.
Then it could escape in one flight with probability p, in two flights with probability qp, three flights with probability q2p and n flights with probability q(n-1)p.
What, I thought to myself, is the average number of flights before it escapes?
I lay on my back in total darkness. Physically paralysed, my mind was trapped in an obsessive tunnel - forced to follow this computational path through to the end.
Right, the expected number of flight 'trials' - N - is one times p + two times qp + three times q2p and so on.
N = p + 2qp + 3q2p + ... + nq(n-1)p + ...
N = p(1 + 2q + 3q2 + ... )
N = p d/dq(q + q2 + q3 ....) = p d/dq(1/(1-q) - 1)
N = p/(1-q)2 = p/p2 = 1/p
You know, I kind of guessed it would be that.
So what's p? I estimated the the bathroom as 1.3 by 1.5 by 2 metres. Total area 15 m2. The open window was around 40 cm by 10 cm of freedom, so 0.04 m2.
Dividing, this gave me p as 2.7 x 10-3, which is roughly e/1000 by happenstance.
So the mean number of trials the moth would need to make before escaping was 1/p, so 0.37 x 103. Around 370 flights.
How fast do moths fly? Well, I reckon about 10 m/s, so it could traverse half the bathroom (the average flight length) in about one tenth of a second. So to escape it would need 37 seconds.
I decided to give it a minute, to be on the safe side.