We discussed another interesting question at work, this time over Slack. This one seemed more mathematical than programming-based, though.

Four small ducks are in a large circular pond. They can be at any point in the circle, with equal probability. What is the probability that a diameter can be drawn so that all four ducks are in the same semicircle in the pond?

Naturally, there is a straightforward generalisation:

N small ducks are in a large circular pond. They can be at any point in the circle, with equal probability. What is the probability that we can fence off some sector of the pond which subtends an angle P, so that all four ducks are enclosed in the fenced area?

If I had to do this as part of an engineering problem, my first reaction would be to implement a Monte Carlo simulation. This would quickly reveal an answer of for the first part, but in the second part things might become less obvious.

Usually for this kind of problem I tend to start by varying some of the parameters and trying to solve a simpler version of the problem. With one duck, drawing a suitable diameter is trivial; with two, drawing a diameter through one of the ducks is sufficient (since the second duck is on one side or the other – ‘small’ here means that we don’t consider the case where a duck lies exactly on the diameter). Going up to three, things get a little complicated; depending on the position of the first two ducks, the third duck can either be placed anywhere (if the first two ducks are at the same location, for example) or perhaps might be quite restricted (if the ducks are on *almost* opposite sides of the pond).

I then looked at other possible ways of simplifying the problem. For example, we don’t really care about where the ducks are relative to the centre of the pond. The relative angles between the ducks and the centre of the pond suffice to identify whether drawing the diameter is possible, and how far they are from the centre of the pond on a given axis won’t affect this. We can thus consider the ducks as uniform randomly occupying points on a looping one-dimensional continuum, such as the interval .

Returning to three ducks, we can try to formalise the intuition that the range of positions allowed for the third duck varies depending on the position of the first two ducks. Define the *span of n ducks* to be the total space on the continuum that the ducks occupy. For base cases, we define , and is just the smaller distance between the first and second duck, so it has to be uniformly distributed between 0 and 0.5.

If we fix the value of , we can attempt to find the range of allowable third-duck positionings such that . Without loss of generality, suppose the two ducks are sitting at points 0 and . Then, the lowest possible point the third duck can sit at would be , and the highest possible point (assuming of course ; if this is not the case then there are clearly no possible positions). The range of this interval is , and the probability that a duck lands in that range is . This of course makes the assumption that is less than 1; if it is more than 1, then the probability would be 1; however, in our specific case since and we don’t have to worry about this.

This then reduces to a problem about conditional probabilities. We want to weight each possible value of based on how likely it is; the relative likelihood of each value is given by the *probability density function*. For , we have

Then, weighting based on this density function, we have:

If then that will be equal to

Thus we can find a diameter for of cases with three ducks. If , then we need to make several refinements – most obviously, the upper bound of the integral stops at 0.5, as there’s no span with two ducks larger than that. Furthermore, there may be values of where in which case we need to clamp it down to 1. For simplicity, we focus on the case where which is sufficient for our purposes.

Moving on, to find , we can similarly formulate

may not seem immediately obvious, but we can rely on the CDF of which was calculated earlier – the probability density function is simply its derivative. Thus , and the conditional probability can be handled with the same logic that we used to go from to , bearing in mind that the middle duck(s) aren’t important. Hence

and we have the answer to the original question, by substituting we obtain an answer of .

Interestingly, the CDFs of the various seems to take on the form . We can prove this result by induction on . This clearly holds for , based on our work so far – though note that is enough for our proof. So we now take some arbitrary integer , and assume that . We need to show that . The way we can do this is very similar to what we did for the concrete steps.

Since we’re assuming that , . We can simplify out the conditional probability term, based on a similar argument on the conditional probability as before. Thus

What follows is a bit of careful rewriting:

And we can simplify this to:

which was what we expected. This also allows us to draw more specific conclusions – for example, in general for the probability is just simply for ducks.