Wednesday, October 26, 2022

Asymptotic Probability of not finding a pair

Consider the problem of finding the probability of not finding a pair (not two consecutive cards of the same rank) from a well shuffled pack. We already discussed this problem in this post where I could this stackexchange post that uses Generating function to solve the problem.

I was eventually able to understand the Generating function approach in the SE post. I'll postpone that for a later post as we'll be looking at something equally interesting in this post. We'll be using the usual well known approach that is indispensable in this type of problems.

Using the ideas in the SE post, we see that the probability of not finding a pair in a pack of well shuffled deck is given by the integral,

$\displaystyle \mathbb{P}(\text{No pair})=\frac{1}{52!}\int_0^\infty e^{-z} (z^4-12z^3+36z^2-24z)^{13}\,dz$

Notice that this is not exactly in the form given in the SE post but we'll probe how the two expressions are equivalent in a later post. For now, let's focus just on the integral. Let,

$\displaystyle I_{4,n}=\int_0^\infty e^{-z} (z^4-12z^3+36z^2-24z)^n\,dz$

To apply Lapalce's method, we manipulate the above like as shown below.

$\displaystyle I_{4,n}=\int_0^\infty e^{n(-z/n+\ln(z^4-12z^3+36z^2-24z))}\,dz$

We now need the value of $z=z_0$ where the function $f(z)=-z/n+\ln(z^4-12z^3+36z^2-24z)$ is maximized. Here's where things get a little interesting.

Even though, it seems to be very hard to find the exact value of $z_0$, with some experimentation, it seems $z_0 \approx 4n+3$ for large $n$.

Expanding $f(z)$ at $z=4n+3$ and keeping terms upto $O(n^{-1})$, we see that

$\displaystyle f(z)\approx -4-\frac{3}{n}+\ln f(4n+3)-\frac{(z-4n-3)^2}{8n^2}$

Therefore,

$\displaystyle I_{4,n}\approx e^{-4n-3}(256n^4-288n^2-96n+9)^n \int_{-\infty}^\infty e^{\frac{-(z-4n-3)^2}{8n}}\,dz$

Using the Normal approximation, we then have,

$I_{4,n} \approx e^{-4n-3}(256n^4-288n^2-96n+9)^n\sqrt{2\pi}\sqrt{4n}$

Let $\mathbb{P}_{j,n}(\text{No Pair})$ be the probability of getting no pair in a pack of $nj$ cards where each card has an integer from $1$ to $n$ and each integer has $j$ cards. Then,

$\displaystyle\mathbb{P}_{j,n}(\text{No Pair})=\frac{I_{j,n}}{(nj)!}$

Using Stirling's approximation, we know that

$n!~\approx \sqrt{2\pi n}e^{-n}n^n$

Therefore,

$\displaystyle \mathbb{P}_{4,n}(\text{No Pair})\approx \frac{e^{-4n-3}(256n^4-288n^2-96n+9)^n\sqrt{2\pi}\sqrt{4n}}{\sqrt{2\pi}\sqrt{4n}e^{-4n}(4n)^{4n}}$

Simplifying further, we get

$\displaystyle \mathbb{P}_{4,n}(\text{No Pair})\approx e^{-3}\left(1-\frac{288n^2+96n-9}{256n^4}\right)^n\approx e^{-3}\left(1-\frac{9}{8n}\right)$

Doing this for different $j$, I was able to see that, in general,

$\displaystyle \mathbb{P}_{j,n}(\text{No Pair})\approx e^{1-j}\left(1-\frac{(j-1)^2}{2nj}\right)$

For example, this approximation gives $\mathbb{P}_{4,13}(\text{No Pair})\approx 0.0454785$ versus the exact value of $\mathbb{P}_{4,13}(\text{No Pair})=0.0454763$ which is extremely good.

Unfortunately, its not the case always. For example, the approximation above gives $\mathbb{P}_{13,4}(\text{No Pair})\approx 0.00000441615$ versus an actual value, given in the SE post quoted at the beginning of the post, of $0.00000118175$ which is understandable as $n$ in this case is very small.

But using the approximations $e^x\approx 1+x$ and $\ln (1-x)^{-1}\approx x+x^2/2$, we get refine our approximation to give,

$\displaystyle \mathbb{P}_{j,n}(\text{No Pair})\approx e^{-(j-1)}e^{\frac{-(j-1)^2}{2nj}}\approx \text{exp}\left(-nj \ln\left(\frac{1-j^{-1}}{n}\right)^{-1}\right)=\left(1-\frac{1-j^{-1}}{n}\right)^{nj}$

Now this 'hand-wavy' approximation gives

$\mathbb{P}_{4,13}(\text{No Pair})\approx 0.045501$ and $\mathbb{P}_{13,4}(\text{No Pair})\approx 0.00000118835$

which is much better in both the cases and gives us some us some reason to take the 'hand-waviness' seriously.

Until then
Yours Aye
Me

Sunday, September 25, 2022

Sunrise Problem - With Replacement

The famous Laplace Sunrise problem asks for the probability of the sun rising tomorrow given that it has risen for the past $n$ days. In this post, we generalize this problem to a setup where the population size is finite and how it changes the required probability.

Mathematically, we are looking for the posterior distribution of the unknown parameter $p$ such that

$X|p \sim \text{Bin}(n,p)$ and $p \sim \text{Beta}(\alpha,\beta)$

It is then well known that the posterior distribution is

$p|X \sim \text{Beta}(\alpha + X, \beta + n - X)$

Therefore, if we start with a uniform prior for $p$ so that $p \sim \text{Beta}(1,1)$ and given that $X=n$, then $p|X=n \sim \text{Beta}(1+n,1)$. Then

$\displaystyle \mathbb{E}(p|X)=\frac{n+1}{n+2}$

We now consider the following problem: Let's say we have an Urn containing $N$ balls such that some are white and rest are black. Let's say we draw $n_1$ balls from the Urn without replacement and observe the number of white balls. We then take $n_2$ balls from the Urn. Now, what is the probability distribution of the number of white balls in the second sample?

Casting the given information in mathematical terms, we have

$X_1|K \sim \text{HG}(N,K,n_1)$
$X_2|K-X_1 \sim \text{HG}(N-n_1,K-X_1,n_2)$ and
$K \sim \text{Beta-Bin}(N,\alpha,\beta)$

where the Beta-Binomial distribution is the discrete analog of the Beta distribution and has the discrete uniform distribution as the special case when $\alpha=\beta=1$. Note that we are looking for $X_2|X_1$.


$K-X_1|X_1 \sim \text{Beta-Bin}(N-n_1,\alpha+X_1,\beta+n_1-X_1)$

We now take a detour into a slightly different problem.

Let $Y|X \sim \text{HG}(N,K,n)$ and $K \sim \text{Bin}(N,p)$. What would be the unconditional distribution of $Y$?

We can get into an algebraic mess of expression to solve this but let's do it with a story proof. Let's say we have $N$ marbles each of which is painted either green (with probability $p$) or red and put into a bag. If we now draw $n$ marbles from the bag without replacement, what is the probability distribution of the green marbles?

With some thinking, it should be easy to easy that this is exactly what we have interms of $X$ (number of marbles painted green) and $Y$ (number of green marbles drawn) above. I posted this on reddit of which one particular reasoning was way better than mine which I give here.

If we don't know $X$, it is as good as saying that the colored marbles are wrapped in an opaque cover before being put in the bag. Therefore, the drawn marbles are no different from each other and unwrapping them after being drawn, we would find a marble to be green with probability $p$ and red otherwise. Therefore,

$Y \sim \text{Bin}(n,p)$

Notice that $N$ disappears and contributes nothing to the unconditional distribution. This result holds even if we replace the $\text{Bin}$ distribution with a $\text{Beta-Bin}$ distribution.

We now get back to our original problem. Knowing $X_2|K-X_1$ and $K-X_1|X_1$, we can immediately see that $X_2|X_1$ is Beta-binomially distributed. Therefore,

$X_2|X_1 \sim \text{Beta-Bin}(n_2,\alpha+X_1,\beta+n_1-X_1)$

If, for example, we started with an Urn of $N$ balls (in which some are white and some are black) and drew $n$ balls without replacement and found all of them to be white, then

$X_2|X_1=n \sim \text{Beta-Bin}(n_2,1+n,1)$

If the size of the second sample is 1, then this clearly shows that

$\displaystyle \mathbb{E}(X_2|X_1)=\frac{n+1}{n+2}$

Very surprisingly, this is exactly the same answer we would get even if we had made the draws with replacement (which is exactly the Sunrise problem)!!

We have so far generalized the Birthday problem, the Coupon collector problem and the problem of points in our blog and in every case, the 'finiteness' of the population alters the final result in one way or the other. Even in this case, at the onset, I doubt that very few would feel that the probability would remain unchanged in the finite case.

Until then
Yours Aye
Me

Expected number of cards drawing two Aces in a row

Let's say we shuffle a standard 52-card deck and draw cards one by one looking for.consecutive cards that form a pair (two cards with the same rank).

I was interested in this question after seeing this StackExchange post. Though the post does not offer an exact solution, the approximate solution given there was really interesting. When I solved the question finding the exact solution, I was really surprised by how good the approximation is.

In this post, we will solving a similar question both exactly and approximately. We are interested in the expected number of draws without replacement before drawing two Aces in a row.

Just to be clear, there may be cases we exhaust all the cards without finding two Aces in a row. In these cases, the number of cards drawn will obviously be 52.

Let $N$ be the random variable indicating the number of draws and we want $\mathbb{E}(N)$.

To solve this in exact form, we first need the probability of drawing $j$ Aces when drawing $k$ cards from the deck such that the Aces are not together. Let's denote this event by $T_{j,k}$. Then it is easy to see that,

$\displaystyle\mathbb{P}(T_{j,k})=\mathbb{P}(j\text{ Aces in }k\text{ draws})\mathbb{P}(\text{Aces are not consecutive})$

The first term is textbook Hypergeometric. For the second term, we lay the $k-j$ non-Ace cards giving us $k-j+1$ spaces between them. We simply have to $j$ spaces out of these for the Aces. Therefore,

$\displaystyle\mathbb{P}(T_{j,k})=\frac{\binom{4}{j}\binom{48}{k-j}}{\binom{52}{k}}\cdot \frac{\binom{k-j+1}{j}}{\binom{k}{j}}$

Therefore, the probability that $N>k$ i.e. we have no consecutive Aces from a set of $k$ cards drawn from the deck is

$\displaystyle\mathbb{P}(N>k)=\sum_{j=0}^4\mathbb{P}(T_{j,k})$

Note that $N$ can only take values between $0$ and $52$ (both inclusive). Therefore,

$\displaystyle\mathbb{E}(N)=\sum_{k=0}^{51}\mathbb{P}(N>k)=\sum_{k=0}^{51}\sum_{j=0}^4\mathbb{P}(T_{j,k})$


$\displaystyle\mathbb{E}(N)=\frac{257026}{5525}\approx 46.5205$

The simplified fraction kind of hints that there may be a more direct way of solving this. I'll update if I find something on this.

To solve this approximately, note that $\mathbb{P}(N>0)=\mathbb{P}(N>1)=1$. Also,

$\displaystyle \mathbb{P}(N>2)=\mathbb{P}(\text{first two cards are not consecutive Aces})=1-\mathbb{P}(\text{first two cards are Aces})=1-\frac{4}{52}\frac{3}{51}=\frac{220}{221}$

Now comes the approximation. On each subsequent draws, we assume that the probability that the current and the previous draw does not form two consecutive Aces is still $220/221$ and that each of these draws are independent. Therefore,

$\displaystyle \mathbb{P}(N>k)\approx\left(\frac{220}{221}\right)^{k-1}$ for $k>0$

This gives

$\displaystyle\mathbb{E}(N)=\mathbb{P}(N>0)+\sum_{k=1}^{51}\mathbb{P}(N>k)\approx 1+\sum_{k=1}^{51}\left(\frac{220}{221}\right)^{k-1}\approx 46.6350$

That's already a great approximation deviating from the correct value by less than quarter of a percentage.

If we further use a exponential approximation (which can also be obtained directly using a Poisson approximation), we have

$\displaystyle \mathbb{E}(N)\approx 1+51\frac{1-e^{-51\cdot 1/221}}{51\cdot 1/221}\approx 46.5431$

That's an insane level of accuracy!!

The following Mathematica code is used for this post.

Clear["Global`*"];
ProbG[k_] := Sum[Binomial[k - j + 1, j] / Binomial[k, j] * Binomial[4, j] Binomial[48, k - j] / Binomial[52, k], {j, 0, Min[4, k]}];
res = Sum[ProbG[k], {k, 0, 51}];
N[res, 15]
lam = 51 * Binomial[4, 2] / Binomial[52, 2];
approx = 1 + 51 * (1 - Exp[-lam]) / lam;
N[approx, 15]
p = Binomial[4, 2] / Binomial[52, 2];
approx = 1 + (1 - Power[1 - p, 51]) / p;
N[approx, 15]

The following code is the simulation for the problem.

Clear["Global`*"];
n = 10000000;
res = 0;
Do[
    test = Split[Mod[RandomSample[Range[0, 51]], 13]];
    Do[
        If[Length[k] <= 1,
            res += 1;,
            If[First[k] > 0, res += Length[k];, res += 2; Break[];];
        ];
    ,{k, test}
    ];
, {j, n}
];
res / n
N[%]

Until then
Yours Aye
Me

Monday, August 22, 2022

Factorial moments of the Binomial and related distributions

Factorial moments are defined as the expected value of the falling factorial of a random variable. In this post, we are going to try to compute the (scaled) Factorial moments of certain distributions without a direct computation.

The Factorial moment of a random variable $X$ is given by

$$\mathbb{E}[(X)_r]=\mathbb{E}[X(X-1)(X-2)\cdots (X-r+1)]$$

For our purposes, we focussing on the following definition which differs from the above only by a constant factor.

$$\displaystyle\mathbb{E}\left[\binom{X}{r}\right]=\mathbb{E}\left[\frac{(X)_r}{r!}\right]$$

Let's start with the famous Binomial distribution. The Binomial random variable $X$, with parameters $n$ and $p$, is the number of successes in a sequence of $n$ independent draws (with replacement), each with a success probability $p$.

Taking a cue from Problem of 7 of Strategic Practice 8 of Stat 110, $\binom{X}{k}$ denotes the set of draws where all the draws in the set result in a success. Creating an Indicator random variable for each set and using the linearity of expectations, we have

$$\displaystyle\mathbb{E}\left[\binom{X}{k}\right]=\binom{n}{k}\cdot p^k$$

We now move on to the Hypergeometric distribution (which is exactly the Stat 110 problem quoted above). Let $X$ denote the number of white balls from an Urn containing $N$ balls of which $K$ are white in a sample of $n$ draws. This is exactly the same problem given in Stat 110 quoted above.

$$\displaystyle\mathbb{E}\left[\binom{X}{k}\right]=\binom{n}{k}\cdot \frac{\binom{K}{k}}{\binom{N}{k}}$$

That is, we've considered an Indicator random variable for each $k$-set of draws and used the Linearity of Expectation. Note that $X$ is the number of successes where a 'success' is viewed as draw that gives a white ball.

Alternately, we can view a 'success' as a white ball that gets drawn. This way, we can solve the problem by considering an Indicator random variable for each $k$-set of white balls. Then,

$$\displaystyle\mathbb{E}\left[\binom{X}{k}\right]=\binom{K}{k}\cdot \frac{\binom{k}{k}\binom{N-k}{n-k}}{\binom{N}{n}}$$

Again, using the Linearity of Expectation, we restrict our attention to only a particular $k$-set of white balls. The probability that we are interested is that this particular set gets drawn when drawing $n$ balls. This is again a Hypergeometric distribution where only this particular set constitute 'successes' and rest are considered failures.

We now get to the Negative Binomial distribution with parameter $p$ and $j$ where $X$ denotes the number of failures we encounter before the $r$'th success. It can be verified with direct calculation that

$$\displaystyle\mathbb{E}\left[\binom{X}{k}\right]=\binom{k+r-1}{k}\left(\frac{q}{p}\right)^k$$

While the calculation is itself is not hard, I could not get a nice 'story' proof for the above. Rather we come back to this problem after the next case.

We now move to the Negative Hypergeometric distribution which will be most interesting aspect of this post. Here, again in the context of Urn and balls, $X$ denotes the number of black balls (failures) we get before the $r$'th white ball (success) from a population of $N$ balls in which $K$ are white.

Here again, $\binom{X}{k}$ denotes the $k$-set of draws that are black balls (failures) that gets drawn before the $r$'th white ball (success). Let $I_j,j \in \{1,2,\cdots,N-K\}$ be $1$ if the $j$th black ball (failure) gets drawn before the $r$'th white ball (success) and $0$ otherwise. Let the indicator random variable $I_S$ be the product of all the indicator random variable in the set $S$. Then,

$\displaystyle\mathbb{E}\left[\binom{X}{k}\right] =\sum_{S_k \subset \{1,2,\cdots,N-K\}}\mathbb{E}(I_{S_k})=\binom{N-K}{k}\mathbb{E}(I_1I_2\cdots I_k)=\binom{N-K}{k}\mathbb{P}(E)$

where $S_k$ denotes a $k$-element subset and $E$ denotes the event that failures $1$ to $k$ occur before the $r$'th success.

In other words, the probability that we want is the probability that we draw (without replacement) $k$ specific black balls from a bag containing $K$ white balls and $N-K$ black balls before the $r$'th white ball. This is a nice question by itself.

The key is to realise that we are concerned only about the $k$ specific black balls. This means we can completely ignore the remaining $N-K-k$ black balls and focus only on the $K$ white balls and the specific $k$ black balls.

The probability that we want is then the probability of getting $k$ black balls before the $r$'th white ball from an Urn containing $K+k$ balls of which $K$ are white. But that is exactly Negative Hypergeometric. Therefore,

$\displaystyle \mathbb{E}\left[\binom{X}{k}\right]=\binom{N-K}{k}\binom{k+r-1}{k}\frac{\binom{K+k-k-r}{K-r}}{\binom{K+k}{K}}=\binom{k+r-1}{k}\frac{\binom{N-K}{k}}{\binom{K+k}{k}}$

Alternately, the required probability can be seen as the probability of drawing $k$ black balls and $j-1$ white balls from an Urn containing $K+k$ balls of which $K$ are white. Then,

$\displaystyle \mathbb{E}\left[\binom{X}{k}\right]=\binom{N-K}{k}\frac{\binom{k}{k}\binom{K}{r-1}}{\binom{k+K}{k+r-1}}=\binom{N-K}{k}\frac{\binom{K}{r-1}}{\binom{k+K}{k+r-1}}$

Now we get back to the Negative Binomial case. Though I can't get a nice story proof for it, we can note that the first expression of the Negative Hypergeometric can be alternatively written as

$\displaystyle \mathbb{E}\left[\binom{X}{k}\right]=\binom{k+r-1}{k}\frac{\binom{N}{K+k}}{\binom{N}{K}}$

Using the asymptotic expression we derived in an earlier post, we can see that it matches with the result that we got from a direct calculation.

Hope you enjoyed the discussion. See ya in the next post.

Until then
Yours Aye
Me

Thursday, July 7, 2022

The Inverse Sum Theorem

This post talks about the 'Inverse Sum theorem' which is at the heart of the video for my SoME2 submission.


Consider two right angled triangles $OAC$ and $OBC$ having a common side $OC=1$ and right angled at $O$. Let $F$ and $E$ be the foot of altitude of the hypotenuse of the respective triangles. Let the line connecting $E$ and $F$ meet the $x$-axis at $D$. We claim that

$$\frac{1}{OD}=\frac{1}{OA}+\frac{1}{OB}$$

We give three proofs of this result with Coordinate geometry.

Co-ordinate Geometry
Let $\angle OCA=\alpha$. Because $OC=1$, we can immediately see that $OA=\tan \alpha$, $CA=\sec \alpha$ and $OF=\sin \alpha$. As $\angle AOF=\alpha$, the co-ordinates of point $F$ can be seen to be $F \equiv (\sin \alpha \cos \alpha, \sin^2 \alpha)$.

Similarly, if we have $\angle OCB=\beta$, then we have $E \equiv (\sin\beta \cos\beta, \sin^2\beta)$

Then the equation of line $EF$ is
$$\frac{y-\sin^2\beta}{\sin^2\alpha-\sin^2\beta}=\frac{x-\sin\beta\cos\beta}{\sin\alpha\cos\alpha-\sin\beta\cos\beta}$$
$D$ is the point on where this line meets the $x$-axis. Therefore, using $y=0$ in the above equation and solving for $x$ gives us $OD$. After some algebraic manipulations, this gives us 
$$x=\frac{\tan\alpha\tan\beta}{\tan\alpha+\tan\beta}$$
Therefore,
$$\displaystyle\frac{1}{OD}=\frac{1}{\tan\alpha}+\frac{1}{\tan\beta}=\frac{1}{OA}+\frac{1}{OB}$$

Trigonometry
Using the generalized Angled Bisector theorem in triangle $OEB$,
$$\frac{OD}{DB}=\frac{OE\sin\angle OED}{BE\sin\angle BED}$$
Using the law of Sines in triangle $OEB$, we get $OE\sin\angle EOB=BE\sin\angle EBO$. Therefore,
$$\frac{OD}{DB}=\frac{\sin\angle EBO}{\sin\angle EOB}\frac{\sin\angle OED}{\sin\angle BED}$$

But $\angle EOB$ and $\angle EBO$ are complementary. So are $\angle BED$ and $\angle OED$. Therefore,
$$\frac{OD}{DB}=\frac{\tan\angle EBO}{\tan\angle BED}=\frac{OC}{OB}\frac{1}{\tan\angle BED}$$

If we now draw a circle with $OC$ as diameter, we know that $E$ and $F$ must lie on this circle because of Thales theorem. Also, $OEF$ and $OCF$ must be equal because they are angles subtended by the chord $OF$. Therefore,
$$\angle BED=90^\circ - \angle OEF=90^\circ-\angle OCF=\angle OAC$$
Therefore,
$$\frac{OD}{DB}=\frac{OC}{OB}\frac{OA}{OC}\implies \frac{OD}{OB-OD}=\frac{OA}{OB}$$
Solving for $OD$, we get the desired result.

Circle Inversion
Using the diagram from above, we see that $OD^2=DF\cdot DE$ because of the tangent-secant theorem. If we imagine a circle $c$ with center $D$ and $OD$ as radius, then the above relation tells us that $E$ and $F$ are inverses of each other w.r.t circle $c$.

Here comes the nice part. Consider two points $U$ and $V$ which are reflections of each other w.r.t a line $l$. Let's say $U$, $V$ and $l$ are all reflected w.r.t a line $m$ to give $U'$, $V'$ and $l'$. Now it should be easy to see that $U'$ and $V'$ are reflections of each other w.r.t line $l'$. The amazing thing here is that this relation holds in case of Circle inversion as well.

Now imagine a circle $c'$ with $C$ as center and $CO$ as radius. Point $O$ is invariant as under an inversion w.r.t $c'$. Points $F$ and $A$ become inverses of each other under $c'$ whereas $E$ and $B$ become inverses. Circle $c$ we described above is invariant as it is orthogonal to Circle $c'$.

We know that $E$ and $F$ are inverses w.r.t $c$. Therefore, $A$ (inverse of $F$ w.r.t $c'$) and $B$ (inverse of $E$ w.r.t $c'$) must be inverses of each other w.r.t $c$ (which is its own inverse under an inversion in $c'$).

The cross ratio $\lambda$ of any four points $A$, $B$, $C$ and $D$ is defined as
$$\lambda=\frac{AB}{AC}\frac{CD}{BD}$$
If one of these points is at infinity, then the terms containing that point disappear from the definition. It is amazing that Cross ratio is invariant under Circle inversion.

The Cross ratio of $O$, $D$, $A$ and $B$ is then
$$\lambda=\frac{OD}{OA}\frac{AB}{DB}$$

The inverses of these points under an inversion w.r.t $c$ become $O$, $\infty$, $B$ and $A$. Therefore, the cross ratio after inversion is
$$\lambda=\frac{BA}{OB}$$
Because cross ratio is invariant under inversion. we have,
$$\frac{OD}{OA}\frac{AB}{DB}=\frac{BA}{OB} \implies \frac{OD}{DB}=\frac{OA}{OB}$$
which is the same relation we had in the previous case.

Interestingly, we also see that $OD^2=DA\cdot DB$ because $A$ and $B$ are inverses of each other w.r.t a circle with radius $OD$.

Until then
Yours Aye
Me

Wednesday, May 18, 2022

Expected values with Bertrand's Paradox

Bertrand's paradox is a neat problem that shows what happens when we take the words 'at random' a bit too casually. In this post, we will be looking at some problems in the same setup and how the different methods yield answers for the 'seemingly' same question.

Bertrand's paradox asks for the probability of a 'random' chord in a unit circle being longer than the side of an inscribed triangle. We are interested in the expected length of such a chord. We now see how the expected length varies if we choose the chord according to the three methods in the paradox.

(1) Circumference method
In this method, we choose two points uniformly randomly on the circumference of the circle and connect those points to create the chord. After the first point is chosen, the second point is uniformly distributed in the circumference.

With this method, if we draw a tangent at the first point, then the angle between the chord and the tangent is uniform in the range $(0,\pi)$. If we let that angle be $\theta$, then the length of the chord is simply $2\sin\theta$. Therefore,

$\displaystyle\mathbb{E}(L)=\int_0^{\pi/2}2\sin\theta\,\frac{d\theta}{\pi/2}=\frac{4}{\pi}\approx 1.2732$

(2) Radial method
In this method, we first choose a random radius. We then choose a point uniformly on this radius and draw a chord perpendicular to this line. If we let $x$ be the length of the point from the origin, then the length of the chord is $2\sqrt{1-x^2}$.

Because $x$ is uniform in $(0,1)$, we have

$\displaystyle \mathbb{E}(L)=\int_0^12\sqrt{1-x^2}dx=\frac{\pi}{2}\approx1.5708$

But here's something interesting. If we use $x=\cos\theta$ in the above integral, the integral becomes,

$\displaystyle \mathbb{E}(L)=\int_0^{\pi/2}2\sin\theta\cdot\sin\theta\,d\theta$

From what we saw in the 'Circumference method', we know that the $2\sin\theta$ denotes the length of the chord. Hence, whatever remains after that must be the PDF of the variable $\theta$.

Therefore, the PDF, $f(\theta)$, for this case is $\displaystyle f(\theta)=\sin\theta$

(3) Midpoint method
Here, a point is chosen randomly in the circle and the unique chord which has this point as the midpoint is drawn. The expected length is slightly tricky here. The trick is to identify the parameter of interest here is the distance of the point from the origin.

If we let $r$ be that distance, then the length of the chord is $2\sqrt{1-r^2}$. But $r$ is not uniform. It is well known that the density of function of $r$ is $2r$ for a unit circle. We then have

$\displaystyle \mathbb{E}(L)=\int_0^12\sqrt{1-r^2}\cdot 2r\,dr=\frac{4}{3}\approx 1.3334$

If we use the substitution $r=\cos\theta$ in the above integral, we can see that the PDF of $\theta$ in this case is $f(\theta)=\sin2\theta$

(4) Random point and line at random angle method
The video also specifies another method of creating a chord which involves choosing a point randomly in the circle and drawing a line at a random angle through this point. To make things clear, let the $r$ be the distance between the point and other centre of the circle.

Now we draw a line perpendicular to the radial line containing this point. The angle, $t$, that the random line (that we draw to create the chord) makes with this perpendicular line is uniformly distributed between $(0,\pi)$.

It can shown then the distance of the random chord and the centre of the circle is then $r\cos t$. Therefore,

$\displaystyle \mathbb{E}(L)=\int_0^{\pi/2}\int_0^12\sqrt{1-(r\cos t)^2}\cdot 2r\,dr\frac{dt}{\pi/2}=\frac{16}{3\pi}\approx 1.69765$

The above integral was solved using Wolfram Alpha.

Here we use the substitutions $u=r\cos t$ and $v=r\sin t$. Then we know that $dudv=rdrdt$. The limits of $r$ and $t$ covers the first quadrant of the unit circle and so should the limits of $u$ and $v$. Therefore,

$\displaystyle \mathbb{E}(L)=\int_0^{1}\int_0^{\sqrt{1-u^2}}2\sqrt{1-u^2}\cdot 2\,\frac{dvdu}{\pi/2}=\int_0^{1}2\sqrt{1-u^2}\cdot 2\sqrt{1-u^2}\,\frac{du}{\pi/2}$

If we now use $u=\cos\theta$, then we see that

$\displaystyle f(\theta)=\frac{2\sin^2\theta}{\pi/2}$

(5) Random point on a radial line and a line at random angle method
Just for the sake of needlessly complicating things, we look at another method where we choose a point randomly in a randomly chosen radial line and draw a at a random angle through this point (the number of randoms in this sentence!). This is almost exactly like the previous case.

$\displaystyle \mathbb{E}(L)=\int_0^{\pi/2}\int_0^12\sqrt{1-(x\cos t)^2}\cdot \,dx\frac{dt}{\pi/2}=\frac{2}{\pi}(2G+1)\approx 1.80286$

where $G$ is the Catalan constant. Note that this integral can be expressed as the integral of the Elliptic integral of the second kind. With that and some known results, this can also be calculated manually.

Again using the subtitution $u=x\cos t$ and $v=x\sin t$ with the Jacobian $dudv=xdxdt$, we see 

$\displaystyle \mathbb{E}(L)=\int_0^{1}\int_0^{\sqrt{1-u^2}}2\sqrt{1-u^2}\cdot \,\frac{dvdu}{x\cdot\pi/2}$

But $x=\sqrt{u^2+v^2}$. Using this, the fact that the integral of the secant function is the inverse hyperbolic sine of the tangent function and the substitution $u=\cos t$, we can see that the PDF in this case as

$\displaystyle f(\theta)=\frac{\sin\theta\sinh^{-1}(\tan\theta)}{\pi/2}$

That sums up the Expected values. But we can do more. There was a recent Numberphile video on similar lines. The question discussed was to find the probability that two points selected at random in a circle is lies on different sides of a 'random' chord. Here's where the PDFs we've found so far will be really useful. We'll see those in the next post.

Hope you enjoyed this.

Until then
Yours Aye
Me

Candles and Cake problem - Probabilities with Bertrand's Paradox

The video I referred to in the earlier post only shows a Monte Carlo solution but we can find the exact values quite easily using the density functions.

Because the two candles (or points) are assumed to be uniformly randomly distributed in the circle (or the cake), an important parameter that keeps repeating in all the cases below is the area of a circular segment which can given in terms of the central angle $t$ as $(t-\sin t)/2$. The probability that a point randomly chosen in a unit circle lies in this segment is then $(t-\sin t)/2/\pi$.

Note that the density we found in the earlier refers are for the random variable $\theta$, the angle the chord makes with the tangent. The angle subtended by the chord is twice this value.

Let $E$ denote the event that two randomly chosen points on the circle lie on the opposite side of the chord chosen according to the following methods.

(1) Circumference method
Like before, if we let $\theta$ be the angle between the tangent and the chord, the central angle becomes $2\theta$. Therefore, the probability that a point randomly chosen in the circle lies in the segment created by this chord is the ratio of the segment's area to that of the circle. Therefore,

$\displaystyle\mathbb{P}(E)=\int_0^{\pi/2}2\left(\frac{2\theta-\sin2\theta}{2\pi}\right)\left(1-\frac{2\theta-\sin2\theta}{2\pi}\right)\,\frac{d\theta}{\pi/2}=\frac{1}{3}-\frac{5}{4\pi^2}\approx 0.20668$

Even though we can solve this easily, Wolfram Alpha does the job perfectly.

(2) Radial line method
We know from our earlier post that the density function of the tangent angle in this case is just $\sin\theta$. Therefore the required probaility

$\displaystyle\mathbb{P}(E)=\int_0^{\pi/2}2\left(\frac{2\theta-\sin2\theta}{2\pi}\right)\left(1-\frac{2\theta-\sin2\theta}{2\pi}\right)\cdot\sin\theta\,d\theta=\frac{128}{45\pi^2}\approx 0.28820$

This can also be simplified manually, but again Wolfram Alpha minimizes our effort and shows

Note that this is $\pi$ times the expected distance between two points chosen at random inside a circle. Coincidence?

(3) Midpoint method
Again, using the density from the previous post, the probability in this case is,

$\displaystyle\mathbb{P}(E)=\int_0^{\pi/2}2\left(\frac{2\theta-\sin2\theta}{2\pi}\right)\left(1-\frac{2\theta-\sin2\theta}{2\pi}\right)\cdot\sin2\theta\,d\theta=\frac{1}{8}+\frac{2}{3\pi^2}\approx 0.19255$

Simple even without Wolfram Alpha.

(4) Random point and line at random angle method
Like the cases above we use the density function for this case that we already found in the previous post.

$\displaystyle\mathbb{P}(E)=\int_0^{\pi/2}2\left(\frac{2\theta-\sin2\theta}{2\pi}\right)\left(1-\frac{2\theta-\sin2\theta}{2\pi}\right)\cdot2\sin^2\theta\,\frac{d\theta}{\pi/2}=\frac{1}{3}\approx 0.33334$

Solved with Wolfram Alpha.

(5) Random point on a radial line and a line at random angle method
Diving right into the probability with the density function at our disposal,

$\displaystyle\mathbb{P}(E)=\int_0^{\pi/2}2\left(\frac{2\theta-\sin2\theta}{2\pi}\right)\left(1-\frac{2\theta-\sin2\theta}{2\pi}\right)\cdot\sin\theta\sinh^{-1}(\tan\theta)\,\frac{d\theta}{\pi/2}\approx 0.386408$

This time Wolfram Alpha only gives us a numerical approximation. But with Mathematica, we can confirm that the exact value is

$\displaystyle \mathbb{P}(E)=\frac{427+60\pi^2-480\log 2}{180\pi^2}$


For the sake of completion, let's finish this post with one more method that was used in the video. Here, the cut is created by choosing two random points on the circumference while the two candles were chosen randomly on a randomly chosen radius.

The first point on the circumference can be chosen to be the 'south pole' of the circle. After the second point is chosen on the circumference, let the chord subtend an angle of $2t$ at the centre. Using the symmetry of the problem, we can limit the range of $t$ to be in $(0,\pi/2)$.

We now calculate the probability that the first candle lies to the right of the chord and the second on the left. Let the radii selected for the first candle make an angle $x$ with the radius perpendicular to the chord. We get a a non-zero probability only if $-t \leq x \leq t$. When $x$ lies in this range, the probability of the first candle landing to the right of the cut is $1-\cos t/\cos x$ and $0$ otherwise.

Similarly, let $y$ be the angle between the radius chosen for the second candle and the radius perpendicular to the cut. When $-t \leq y \leq t$, the probability of the second candle ending up to the left of the cut is $\cos t/\cos y$. Else, the probability is $1$.

Therefore probability in this case depends on the following two integrals.

$\displaystyle \mathcal{I}_1=\int_0^{\pi/2} \int_{-t}^t \int_{-t}^t \frac{\cos t}{\cos y}\left(1-\frac{\cos t}{\cos x}\right)\,dy\,dx\,dt$

$\displaystyle \mathcal{I}_2=\int_0^{\pi/2} \int_{-t}^t \int_{t}^{2\pi-t} \left(1-\frac{\cos t}{\cos x}\right)\,dy\,dx\,dt$

These are very hard to evaluate even with Mathematica. Numerically evaluating these shows,

$\displaystyle \mathbb{P}(E)=2\cdot\frac{\mathcal{I}_1+\mathcal{I}_2}{\pi/2\cdot 2\pi \cdot 2\pi}\approx 0.161612$

Hope you enjoyed this.

Until then
Yours Aye
Me