# xikka

A collection of things I have made and things I find interesting.

Thursday, 1st November 2018 ◆ A bard trod clumsily on cork circle (9)

Imagine throwing a dart at a dartboard such that it will hit any point on the dartboard uniformly randomly. What is the expected distance between the dart and the centre of the dartboard?

Firstly, a clarification. When I say "uniformly randomly", I mean the probability of a dart landing in any particular location is the same as any other location.

You may like to try and work out the answer before I delve in. What seems about right to you?

I'm going to solve this in two ways. Firstly, a mathsy way which requires a little bit of probability knowledge. Then, I'll try an intuitive method which is less rigorous, but which might be more satisfactory.

### Mathsy method

First, let's consider an inner circle on the dartboard with radius $$d$$, I'll call this section $$I_d$$. Note that this is only valid where $$0 \le d \le r$$.

Inner section

The probability of landing in this inner section is simply what percentage of the entire dartboard it takes up. For example, if $$d = r/2$$, the inner circle occupies $$1/4$$ of the dartboard, and so the chance of landing inside it is $$1/4$$.

$$\mathbb{P}(\text{dart lands in}\ I_d) = \frac{\pi d^2}{\pi r^2} = \frac{d^2}{r^2}$$

Let $$D$$ be the random variable which represents the distance between the dart and the centre. For example, if you throw a dart and hit the dead centre, $$D$$ would take the value $$0$$. If you hit somewhere on the edge, $$D$$ would take the value $$r$$.

Doing this, we can represent the probability above in terms of $$D$$:

$$\mathbb{P}(D \le d) = \mathbb{P}(\text{dart lands in}\ I_d) = \frac{d^2}{r^2}$$

This is called the cumulative distribution function, or cdf. We are going to use a theorem which lets us derive the expected value from the cdf. It's explained here if you are interested. This gives us the following integral:

$$\mathbb{E}(D) = \int_0^r 1 - \frac{x^2}{r^2} \text{d}x = \frac{2r}{3}$$

And that is our answer: $$2r/3$$.

### Intuitive method

To find the expected value we sum all the values we can get and divide by the number of values. For example, if we had a die with faces $$(1,2,3,6,6,6)$$ our expected value would be $$\frac{1+2+3+6+6+6}{6}$$.

In our case, the value of an outcome is the distance from the dartboard. The number of values is how many places the dart can land.

$$\mathbb{E}(D) = \frac{\text{sum of all possible distances}}{\text{number of places dart can land}}$$

To find the "sum of all possible distances", imagine the dartboard lies flat. For each point on the dartboard, I will extrude upwards to the height of the distance from the centre of the dartboard. For example, at a distance of $$r$$, the radius of the dartboard, I will extrude a hollow cylinder of height $$r$$. Now do this for every possible distance from the centre:

Inverted cone

Hopefully you can see that we've created an inverted cone. The volume of this shape represents the sum of all the possible distances the dart can land at – for every point we are adding its respective distance from the centre. I'm using the word "sum" loosely here, but I hope you can see general principle.

To find the volume of the inverted cone, we subtract the volume of the cone from that of the cylinder:

\begin{aligned} V_{\text{inverted cone}} &= V_{\text{cylinder}} - V_{\text{cone}} \\ &= \pi r^2 h - \frac{\pi r^2 h}{3} \\ &= \frac{2 \pi r^3}{3} \end{aligned}

The "number of places" the dart can land is simply the area of the dartboard. Finding that is easy, it's $$A = \pi r^2$$.

Combining this together gives us:

$$\mathbb{E}(D) = \frac{V_{\text{inverted cone}}}{A} = \frac{2 \pi r^3 / 3}{\pi r^2} = \frac{2r}{3}$$

We get the same answer: $$2r/3$$. I hope that gives some credence to the mathsy answer!

### What next

The reason I started thinking about this is for a simple problem I've had in game-making. I discuss that in another blog post: round in circles.

That aside, there are so many interesting things to experiment with. What happens if the dartboard is square? If we throw two darts, what's the expected distance between them? If we throw three, what's the expected area of the triangle they define? Have a play, at let me know if you come up with anything cool!