# Random Triangle Inscribed in a Circular Sector

Lately, I have been thinking about expected area and perimeter of a triangle inscribed in a 'partial' circle or circular sector with radius $r$ and truth be told, I couldn't answer these questions. I hope someone here could give me a good answer. Let's say circular sector as $\frac{2\pi}{n}$ circle for $n\in\mathbb{N}$. My questions are:

1. What is expected area and perimeter of a triangle inscribed in a circular sector with radius $r$, where one of its vertex lies on center of the circular sector and the other vertexs are uniformly, independently, and randomly drawn inside the circular sector.
2. What is expected area and perimeter of a triangle inscribed in a circular sector with radius $r$, where one of its vertex lies on center of the circular sector and the other vertexs are uniformly, independently, and randomly drawn along the circumference/ perimeter circular sector.

My approach for the first one is (based on Wolfram MathWorld): \begin{align} \text{E}[A]&=\int_0^r\int_0^r\int_0^{\frac{2\pi}{n}}\int_0^{\theta_1}A(r_1,r_2,\theta_1,\theta_2)\cdot f(r_1,r_2,\theta_1,\theta_2)\,d\theta_1d\theta_2dr_1dr_2\\ &=\int_0^r\int_0^r\int_0^{\frac{2\pi}{n}}\int_0^{\theta_1}\frac{1}{2}\left|\sqrt{r_1r_2}\sin(\theta_1-\theta_2)\right|\cdot \left(\frac{n}{2\pi r}\right)^2\,d\theta_1d\theta_2dr_1dr_2\\ &=\frac{1}{8}\left(\frac{n}{\pi r}\right)^2\int_0^r\int_0^r\int_0^{\frac{2\pi}{n}}\int_0^{\theta_1}\left|\sqrt{r_1r_2}\sin(\theta_1-\theta_2)\right|\,d\theta_1d\theta_2dr_1dr_2,\\ \end{align} where \begin{align} f(r_1,r_2,\theta_1,\theta_2)&=f(r_1)\cdot f(r_2)\cdot f(\theta_1)\cdot f(\theta_2)\\ &=\frac{1}{(r-0)}\cdot\frac{1}{(r-0)}\cdot\frac{1}{\left(\frac{2\pi}{n}-0\right)}\cdot\frac{1}{\left(\frac{2\pi}{n}-0\right)}\\ &=\left(\frac{n}{2\pi r}\right)^2. \end{align} But I didn't quite sure about that especially for the integral limits and the pdf $f(r_1,r_2,\theta_1,\theta_2)$. For the expected perimeter and the second one question, I don't have any idea. Could someone here provide me answers about these problems? I'd be grateful for any help you are able to provide.

• By center of the circular segment I hope you mean center of the arc and not center of the circle? – Sawarnik Feb 19 '14 at 9:05
• @Sawarnik I'm sorry, I mean circular sector. I've already edited it. – Tunk-Fey Feb 19 '14 at 9:11

# First question: sampling from the inside

## Uniform sampling

The way you write it, you choose polar coordinates in what looks uniform.
Thanks to your comment, particularly due to the link on disk point picking, I now see that your formula tries to correct for this sampling method by writing $\sqrt{r_i}$ instead of $r_i$. But that formula, used in this simple way, only works for the unit disk. I approached the problem in a different way, and will keep it that way to avoid these square roots. But I'll include a short section on translating between these worlds.

To get a uniform sampling in the geometric sense, you have to correct for the fact that at larger radii, you have more arc length to sample from, so larger radii should be more common. To phrase this differently, the probability density at a given position $\mathrm r_1$ should be proportional to $r_1$ itself, since the arc of radius $r_1$ has a length proportional to $r_1$. Therefore I'd first compute the factor of proportionality, which has to be chosen such that the probabilities add up to $1$.

$$\int_0^rr_1\,\mathrm dr_1=\frac{r^2}2 \quad\Rightarrow\quad \int_0^r\frac{2r_1\,\mathrm dr_1}{r^2}=1$$

## Using the uniform sampling

Using this term you could write your formulas like this (with the abbreviation $\alpha:=\frac{2\pi}n$):

\begin{align*} E[A] &= \int_0^r\int_0^r\int_0^\alpha\int_0^\alpha \frac{r_1\,r_2\,\sin\lvert\theta_1-\theta_2\rvert}{2} \frac{\mathrm d\theta_1}{\alpha} \frac{\mathrm d\theta_2}{\alpha} \frac{2r_1\,\mathrm dr_1}{r^2} \frac{2r_2\,\mathrm dr_2}{r^2} \\ E[P] &= \int_0^r\int_0^r\int_0^\alpha\int_0^\alpha \left(r_1+r_2+\sqrt{r_1^2+r_2^2-2r_1r_2\cos(\theta_1-\theta_2)}\right) \frac{\mathrm d\theta_1}{\alpha} \frac{\mathrm d\theta_2}{\alpha} \frac{2r_1\,\mathrm dr_1}{r^2} \frac{2r_2\,\mathrm dr_2}{r^2} \end{align*}

I got the area formula from Wikipedia. For the perimeter, I computed the third side using the law of cosines.

You can translate between my radii $r_i$ and your radius-like parameters (which you called $r_i$ but which I'll call $u_i$ for now) using conversions like these:

\begin{align*} r_i &= r\sqrt{\frac{u_i}r} = \sqrt{r\,u_i} & \mathrm dr_i &= \frac{\mathrm d\,r_i}{\mathrm du_i}\mathrm du_i = \frac{r\,\mathrm du_i}{2\sqrt{r\,u_i}} \\ u_i &= \frac{r_i^2}r & \mathrm du_i &= \frac{\mathrm d\,u_i}{\mathrm dr_i}\mathrm dr_i = \frac{2r_i\,\mathrm dr_i}{r} & \frac{\mathrm du_i}r &= \frac{2r_i\,\mathrm dr_i}{r^2} \end{align*}

See how in the first expression, I normalize $u_i$ to the [0,1] range by dividing through $r$, then take the square root as is appropriate for the unit disk, then scale again by $r$. This factor of $r$ is missing inside your square roots. You might however be better of integrating over the [0,1] range, and simply multiplying the final result by $r^2$ resp. $r$ to account for the size of the whole setup. The final equation demonstrates how this translation between worlds would have been an alternative to obtain the correct probability density function for $r_i$.

## Reducing the number of integrals

Next step should probably be eliminating the two angles, and replacing them by a single term for the (absolute value of the) angle difference. But that again needs correct weighting. So as a preliminary step, let's compute the probability that the difference between two angles chosen at random is less than $\varphi$:

\begin{align*} Pr[\lvert\theta_1-\theta_2\rvert<\varphi] &= \int_0^\alpha\int_0^\alpha\begin{cases} 1 & \text{if }\lvert\theta_1-\theta_2\rvert<\varphi \\ 0 & \text{if }\lvert\theta_1-\theta_2\rvert\ge\varphi \end{cases} \frac{\mathrm d\theta_1}{\alpha} \frac{\mathrm d\theta_2}{\alpha} \\&= \frac1{\alpha^2}\int_0^\alpha\left( \min(\theta_1+\varphi, \alpha)-\max(\theta_1-\varphi, 0) \right)\mathrm d\theta_1 \end{align*}

There are two cases to distinguish here: either $2\varphi<\alpha$ or $2\varphi\ge\alpha$. Let's treat the first case, $2\varphi<\alpha$.

\begin{align*} Pr[\lvert\theta_1-\theta_2\rvert<\varphi] &= \frac1{\alpha^2}\left( \int_0^\varphi\left(\theta_1+\varphi\right)\mathrm d\theta_1 + \int_\varphi^{\alpha-\varphi}2\varphi\mathrm d\theta_1 + \int_{\alpha-\varphi}^\alpha\left(\alpha-\theta_1+\varphi\right)\mathrm d\theta_1 \right) \\&= \frac{\tfrac12\varphi^2+\varphi^2+2\varphi(\alpha-2\varphi)+\tfrac12\varphi^2+\varphi^2}{\alpha^2} \\&= \frac{3\varphi^2+2\varphi(\alpha-2\varphi)}{\alpha^2} = \frac{\varphi(2\alpha-\varphi)}{\alpha^2} \end{align*}

Now for the second case, $2\varphi\ge\alpha$.

\begin{align*} Pr[\lvert\theta_1-\theta_2\rvert<\varphi] &= \frac1{\alpha^2}\left( \int_0^{\alpha-\varphi}\left(\theta_1+\varphi\right)\mathrm d\theta_1 + \int_{\alpha-\varphi}^\varphi\alpha\mathrm d\theta_1 + \int_\varphi^\alpha\left(\alpha-\theta_1+\varphi\right)\mathrm d\theta_1 \right) \\&= \frac{\tfrac12(\alpha-\varphi)^2+\varphi(\alpha-\varphi)+(2\varphi-\alpha)\alpha+\tfrac12(\alpha-\varphi)^2+\varphi(\alpha-\varphi)}{\alpha^2} \\&= \frac{\alpha^2-\varphi^2+(2\varphi-\alpha)\alpha}{\alpha^2} = \frac{\varphi(2\alpha-\varphi)}{\alpha^2} \end{align*}

This is really nice: we end up with the same term, so we can avoid the case distinction from now on. The probability density is now the derivative of this term.

$$\frac{\mathrm d}{\mathrm d\varphi} \frac{\varphi(2\alpha-\varphi)}{\alpha^2} = \frac{2(\alpha-\varphi)}{\alpha^2}$$

Short sanity check:

$$\int_0^\alpha \frac{2(\alpha-\varphi)\,\mathrm d\varphi}{\alpha^2} = 1$$

Now you can use this term in your computation:

\begin{align*} E[A] &= \int_0^r\int_0^r\int_0^\alpha \frac{r_1\,r_2\,\sin\varphi}{2} \frac{2(\alpha-\varphi)\,\mathrm d\varphi}{\alpha^2} \frac{2r_1\,\mathrm dr_1}{r^2} \frac{2r_2\,\mathrm dr_2}{r^2} \\ E[P] &= \int_0^r\int_0^r\int_0^\alpha \left(r_1+r_2+\sqrt{r_1^2+r_2^2-2r_1r_2\cos\varphi}\right) \frac{2(\alpha-\varphi)\,\mathrm d\varphi}{\alpha^2} \frac{2r_1\,\mathrm dr_1}{r^2} \frac{2r_2\,\mathrm dr_2}{r^2} \end{align*}

## Computing the integrals

Then you can start moving stuff which does not depend on $\varphi$ out of the innermost integral.

\begin{align*} E[A] &= \frac{4}{r^4\alpha^2} \int_0^rr_2^2\int_0^rr_1^2 \int_0^\alpha \sin\varphi (\alpha-\varphi) \,\mathrm d\varphi \,\mathrm dr_1 \,\mathrm dr_2 \\&= \frac{4}{r^4\alpha^2} \int_0^rr_2^2\int_0^rr_1^2 \left( \alpha\int_0^\alpha \sin\varphi \,\mathrm d\varphi - \int_0^\alpha \varphi\sin\varphi \,\mathrm d\varphi \right) \,\mathrm dr_1 \,\mathrm dr_2 \\&= \frac{4}{r^4\alpha^2} \int_0^rr_2^2\int_0^rr_1^2 \bigl( \alpha(1-\cos\alpha)-(\sin\alpha-\alpha\cos\alpha) \bigr) \,\mathrm dr_1 \,\mathrm dr_2 \\&= \frac{4(\alpha-\sin\alpha)}{r^4\alpha^2} \int_0^rr_2^2\int_0^rr_1^2 \,\mathrm dr_1 \,\mathrm dr_2 \\&= \frac{4(\alpha-\sin\alpha)r^2}{9\alpha^2} \end{align*}

Experiments suggest that this result is indeed correct, at least for $\alpha\le\pi$. For larger $\alpha$, the area formula is no longer correct, since in that case we'd need to use $\lvert\sin\varphi\rvert$. So the case of $n=1$ from your question would need special treatment.

The $E[P]$ thingy is too complicated for my taste just now. If someone wants to handle that, feel free to edit this answer. According to Wolfram Alpha, the result will likely involve elliptic integrals, which in my opinion isn't terribly surprising.

# Second question: sampling from the arc

For the arc cases, things are a lot simpler. You simply drop the outermost two integrals, and assume $r_1=r_2=r$ in the integrand formulas. Unless I made a mistake (so please check), this should be the result:

\begin{align*} E[A] &= \int_0^\alpha\int_0^\alpha \frac{r^2\,\sin\lvert\theta_1-\theta_2\rvert}{2} \frac{\mathrm d\theta_1}{\alpha} \frac{\mathrm d\theta_2}{\alpha} \\&= \int_0^\alpha \frac{r^2\,\sin\varphi}{2} \frac{2(\alpha-\varphi)\,\mathrm d\varphi}{\alpha^2} \\&=\frac{(\alpha-\sin\alpha)r^2}{\alpha^2} \\ E[P] &= \int_0^\alpha\int_0^\alpha \left(2+\sqrt{2-2\cos(\theta_1-\theta_2)}\right)r \frac{\mathrm d\theta_1}{\alpha} \frac{\mathrm d\theta_2}{\alpha} \\&= \int_0^\alpha \left(2+\sqrt{2-2\cos\varphi}\right)r \frac{2(\alpha-\varphi)\,\mathrm d\varphi}{\alpha^2} \\&= 2r + \frac{2\sqrt2r}{\alpha^2}\int_0^\alpha (\alpha-\varphi)\sqrt{1-\cos\varphi}\,\mathrm d\varphi \\&= 2r + \frac{2\sqrt2r}{\alpha^2}\left[ 2\sqrt{1-\cos\varphi}\left((\varphi-\alpha)\cot\frac\varphi2-2\right) \right]_0^\alpha \\&= 2r + \frac{2\sqrt2r}{\alpha^2}\left(2\sqrt2\alpha-4\sqrt{1-\cos\alpha}\right) \\&= 2r + \frac{8r}{\alpha} - \frac{8r}{\alpha^2}\sqrt{2-2\cos\alpha} \end{align*}

• I got the transformation from Wolfram MathWorld. You may also see this. The way I derive the pdf is easy, since it's uniform so I think the pdf for $\theta$ should be like this:$$f(\theta)=\frac{1}{\alpha-0}.$$I don't know, it's that correct or not. Anyway, thank you so much for your answer but I've to check it first to confirm myself that's the right answer. – Tunk-Fey Feb 19 '14 at 16:01
• @Tunk-Fey: thanks for your comment, I now see where you got the square root from, also see that you tried to do uniform sampling. But I think I also spotted a mistake with that. See my updated answer for details. – MvG Feb 19 '14 at 16:36
• I think you made a mistake in second question because the vertices can also lie on the radius of circular sector. That's why I stated in my question "the other vertexs are uniformly, independently, and randomly drawn along the circumference/ perimeter circular sector". In second question there are 3 cases: both vertices lie on the curve line, a vertex lies on radius & another one lies on curve line, and both vertices lie on the radius. – Tunk-Fey Feb 20 '14 at 13:35
• @Tunk-Fey: You are right, I misunderstood the question, assuming only points on the circular arc. At least my answer states what it is assuming. I'd even distinguish four cases: in the last of the three cases you mention, the points can lie on the same or on different radii, right? For each case, you can compute the probability of that case, and the expected value of the area/perimeter within that case. Working out all the formulas will take more time than I'm willing to spend on this, but if you do, you can write your own answer with the details on that. – MvG Feb 20 '14 at 13:49
• Ya, that's what I mean. I do work on this problem but I need more time since I also struggle with my thesis. Honestly, this question is really distracting my focus on my thesis but I think it's worth to try. I'll post my answer if I already solve it and this problem still opens for anyone. Anyway, for the question no. 1, if $n=1$ and $r=1$, your approach and mine for $\text{E}[A]$ have same result. I also notice that the angle in the $\sin$ should be $\sin|\theta_1-\theta_2|$. You've already given me lots of ideas to solve this problem especially for the expected perimeter. Thank you so much. – Tunk-Fey Feb 20 '14 at 14:20