Saturday, April 10, 2021
Expected Value in terms of CDF
Monday, January 18, 2021
Probability on a standard deck of cards
Saturday, January 16, 2021
Probability on a Contingency Table
Contingency tables are quite common in understanding a classification problems like that of a ML model or new drug tested against a disease. Given that we are just recovering from a pandemic, let's stick to the case of a Machine Learning model. In the context of ML models, it is called the Confusion matrix and we'll use both the terms interchangeably in this post.
A 2x2 contingency table usually has two columns for the binary classification (Win vs. Lose, Apple vs. Orange, White vs. Black etc.) and two rows for whether the prediction was right or wrong. Let's consider the classification as a 'Hypothesis' and the model's prediction as an 'Evidence' supporting it.
Here is how our contingency table would look like.
Table 1 |
H |
⌐H |
E |
n(H∩E) |
n(⌐H∩E) |
⌐E |
n(H∩⌐E) |
n(⌐H∩⌐E) |
Table 2 |
H |
⌐H |
E |
$\mathbb{P}(H\cap E)$ |
$\mathbb{P}(\neg H\cap E)$ |
⌐E |
$\mathbb{P}(H \cap \neg E)$ |
$\mathbb{P}(\neg H \cap \neg E)$ |
Thursday, January 7, 2021
Isochrone on a Spherical surface
Monday, November 30, 2020
Tautochrone curve on a Spherical surface
![]() |
Tautochrone curve with $\lambda=\pi/8$ |
Monday, August 3, 2020
Gergonnes's Solution to Apollonius' Problem
As always, the wiki page was a great source of information for me and it gives a very nice account on Gergonne's solution to the problem which, needless to say, is ingenious. Meanwhile, I was also consulting Cut-The-Knot's version of Gergonne's solution.
Both the solutions seemed similar but there was one subtle difference. To make it more clear (and readable), I (re)created the diagrams on Wikipedia using Geogebra. Before we dwell further, let's list out the key labels used in the construction.
In what follows , $i \in \{1,2,3\}$ and $X \in \{A,B\}$
$C_1,C_2,C_3$ - The given circles. In general, there are eight circles that are mutually tangent to all these circles
$C_O$ - Circle orthogonal to all the three given circles
$G$ - Radical center of the given circles. Also, center of the Orthogonal circle $C_O$
$C_A,C_B$ - A pair (out of the possible eight) of solution circles
$X_i$ - Points where the solution circle $C_X$ touches Circle $C_i$
$l_i$ - Line passing through $A_i$ and $B_i$. As $A_i$ and $B_i$ are inverses to each other w.r.t to $C_O$, this line also contains the Radical center $G$; also the polar of point $T_i$ defined below
$p$ - (One out of the possible four) Homothetic Axis. This line also happens to be the radical axis of the solution circles
$P_i$ - Pole of the Homothetic axis $p$ w.r.t to circle $C_i$
$J_i, K_i$ - Points of intersection of the Orthogonal circle $C_O$ and circle $C_i$
$T_i$ - Point of intersection of the line joining $J_i$ and $K_i$, and the Homothetic axis $p$; Also, the pole of line $l_i$ defined above
$O_1,O_2$ - Points of intersection between the Orthogonal circle $C_O$ and Homothetic axis $p$
$C_I$ - Circle with center at $O_1$ and passing through $O_2$
Gergonne's Solution - Wikipedia
(i) Construct $p$, the Homothetic axes (or axes of similitude) (ii) Construct the Radical center $G$ of the three given circles (iii) Construct the poles $P_i$ of the Homothetic axes w.r.t the given circles.
![]() |
Points $P_i$ are the objects of interest in Wikipedia version of Gergonne's Solution |
Now the line joining $G$ and $P_i$ cuts the circle $C_i$ in $A_i$ and $B_i$ giving six points in total. These six points determine the solution circles.
Gergonne's Solution - Cut-The-Knot
(i) Construct $p$, the Homothetic axes (or axes of similitude) (ii) Construct the circle orthogonal to the given circles $C_O$ (iii) Construct the Radical axis of the Orthogonal circle and each of the given circles (that is, the line joining $J_i$ and $K_i$); this intersects the Homothetic axes in $T_i$.
![]() |
Points $T_i$ are the objects of interest in Cut-The-Knot version of Gergonne's Solution |
Now construct tangent from $T_i$ to each of the given circles.These points then determine the solution circles.
The third step in these solutions were the source of my confusion. Especially, while Wikipeida's version needs an inversion (constructing the poles $P_i$), Cut-the-Knot's version needs no inversion at all. This baffled me and it took me some time (two days to be exact) to figure out how this was possible.
The explanation given in Cut-The-Knot did not seem to clarify this point. It quotes Four Touching Circles IV, which does not add anything in relation to the third step in the construction.
Gergonne's solution relies crucially on the inversive relation between poles and polars of conics. In particular, it exploits the fact that if the pole $P$ of a line $p$ w.r.t a conic lies on a line $q$, then the pole $Q$ of line $q$ w.r.t the same conic lies on line $p$. Wikipedia version (and most descriptions of Gergonne's solution) makes use of this relation.
Now, Cut-The-Knot's solution uses the mirror image of the same relation. That is, if the polar $p$ of a point $P$ contains a point $Q$, then the polar $q$ of point $Q$ w.r.t the same conic, contains the point $P$. And hence, it cleverly avoids any explicit inversion construction. Here's how it works.
From Wikipedia, we know that point $T_i$ is the pole of the (polar) line $l_i$ w.r.t circle $C_i$. Now the polar of point $T_i$ contains the point $G$. Hence, the polar of $G$ must contain $T_i$.
Here's comes the nice part. Given any pair of orthogonal circles, the polar of center of either circle w.r.t to the other circle is their radical axis. This is very obvious from the construction of polars and orthogonal circles.
So in essence, we are actually constructing a polar (rather than a pole in Wikipedia's version) of point. However, because of the clever choice, it just happens to be the point of intersection of circles already constructed avoiding the need for any inversion.
That was indeed neat. Hope you agree.
This whole process of revisiting one of the classical problems in Geometry was really nice experience for me. I greatly enjoyed creating the Geogebra drawing of the solution. In fact, I came up with something on my own.
Whenever, the Homothetic axis $p$ meets the Orthogonal circle $C_O$, something very interesting happens. As the solution circles are inverses of each other under $C_O$, the points of intersection between $p$ and $C_O$ also happens to be the points of intersection between $C_A$ and $C_B$.
Now draw a circle $C_I$ with center at one of the points of intersection (Point $O_1$) and passing through the other (Point $O_2$). Use this as a circle of inversion.
As the Orthogonal circle passes through the center of inversion, it becomes a straight line $C_O'$.
The three given circles, being orthogonal to the $C_O$, transforms into circles with their center on the line above.
The solution circles too passes through the inversion center and they too transform into straight lines ($C_A'$ and $C_B'$).
The (other) point of intersection $O_2$ of the solution circles passes through the inversion circle $C_I$ and hence this point is where the solution lines $C_A'$ and $C_B'$ meet. That is, point $O_2$ becomes the Homothetic center of the (inverted) given circles.
![]() |
The given circles (not shown here) inverted under $C_I$ form a set of Homothetic circles with center $O_2$. The Orthogonal circles and both the solution circles transforms to straight lines. |
In summary, if $p$ meets $C_O$, we can construct a circle $C_I$ with center at $O_1$ and passing through $O_2$. Invert any of the given circle and draw tangent lines from $O_2$ to the inverted circle. Inverting back these tangent lines gives the required solution circles.
While constructing inversion is harder (needs more steps) while doing manually, this method is relatively simpler if we have an 'macro' for inversion (as in Computer graphics systems like Geogebra).
But the main drawback about this method is that it only works when the Homothetic axes intersects the Orthogonal circle which, sadly, is not guaranteed when the Homothetic axis contains two external Homothetic centers. Even in this case, we can actually develop a solution using the concept of mid-circles. This is not complicated but is more laborious. Gergonne's solution can be used in these cases.
That's all for today. Hope you enjoyed it.
Until then
Yours aye
Me
Wednesday, June 17, 2020
Error terms of the Exponential Function's limit form
$e^x=\displaystyle\lim_{n \to \infty}\left(1+\frac{x}{n}\right)^n$
Characterizations of the exponential function gives the following as the first few error terms of this limi-expression,
$\displaystyle\left(1+\frac{x}{n}\right)^n=e^x\left(1-\frac{x^2}{2n}+\frac{x^3(8+3x)}{24n^2}-\cdots\right)$
stating that the numerators of the $n^k$ terms are polynomials in $x$ of degree $2k$. However, no mention is made about the computation of the coefficients or their relation with each other (if there is any).
That exactly is the point of this post. We try to derive an expression which allows us to calculate the coefficients as we desire. Considering that this definition of the Exponential function is all over the internet, I was disappointed that I could not find any reference regarding these coefficients.
Based on Wikipedia's expression, we suspect that,
$\displaystyle e^{-x}\left(1+\frac{x}{n}\right)^n=\sum_{i\geq j \geq 0}(-1)^{i}p_{i,j}\frac{x^{i+j}}{n^i}$
where we seek to compute the coefficients $p_{i,j}$. Now using the substitutions $x \to -nx$ and $n \to -1/n$ (in that order), we can see that,
$e^{-x/n}(1-x)^{-1/n}=\displaystyle\sum_{i\geq j \geq 0}p_{i,j}\frac{x^{i+j}}{n^j}$
But $e^{-x/n}(1-x)^{-1/n}=e^{-(x+\ln{(1-x)})/n}=\displaystyle\sum_{j=0}^\infty(-x+\ln{(1-x)^{-1}})^j\frac{1}{n^jj!}$
Comparing the coefficients of powers of $n$, we have,
$x^jp_j(x)=\displaystyle x^j\sum_{i=0}^\infty p_{i,j}x^i=\frac{1}{j!}(-x+\ln{(1-x)^{-1}})^j$
This readily gives a combinatorial representation. That is, $(i+j)!p_{i,j}$ is the number of derangements of $[1,2,3,\cdots,i+j]$ with exactly $j$ cycles. Therefore,
$\displaystyle (i+j)!p_{i,j}=\sum_{k=0}^j (-1)^{j-k}\binom{i+j}{i+k}\begin{bmatrix}i+k\\k\end{bmatrix}=\sum_{k=0}^j (-1)^{i+j-k}\binom{i+j}{i+k}s(i+k,k)$
where $\begin{bmatrix}n\\k\end{bmatrix}$(and $s(n,k)$) are the unsigned (and signed) Stirling numbers of the first kind.
Also, using the same derangement interpretation, we can easily see that,
$\displaystyle \sum_{j=0}^i i!p_{i-j,j}=i!\sum_{j=0}^i\frac{(-1)^j}{j!}\implies \sum_{j=0}^i p_{i-j,j}=\sum_{j=0}^i\frac{(-1)^j}{j!}$
On the other hand, we can derive a recurrence for $p_{i,j}$'s by manipulating $x^jp_j(x)$.
$jxp_j(x)=p_{j-1}(x)(-x+\ln(1-x)^{-1})=\displaystyle p_{j-1}(x)\left(\frac{x^2}{2}+\frac{x^3}{3}+\frac{x^4}{4}+\cdots\right)$
Comparing coefficients of powers of $x$, we have,
$p_{i,j}=\displaystyle\frac{1}{j}\sum_{k=2}^{i+1}\frac{1}{k}p_{i-k+1,j-1}=\frac{1}{j}\sum_{k=0}^{i-1}\frac{p_{k,j-1}}{i-k+1}$
Together with $p_{0,0}=1$ and $p_{i,j}=0$ when $i<j$ (or) $j=0$ enables us to calculate all the coefficients.
Further, we can differentiate $x^jp_j(x)$ to get a different recurrence.
$\displaystyle p_{i,j}=\frac{1}{i+j}p_{i-1,j-1}+\left(1-\frac{1}{i+j}\right)p_{i-1,j}$
This is really magical as we now have a probabilistic interpretation for the $p_{i,j}$'s.
Consider a bot that is initially at point $(i,j)$ with $i\geq j$ in the $x$-$y$ plane. The bot is programmed to move towards the origin such that at each step it either moves down-left to $(i-1,j-1)$ with some probability or moves left to point $(i-1,j)$ with the complementary probability.
If the probability of moving down-right is the inverse of the Manhattan distance between the bot's current position and the origin, then $p_{i,j}$ is the probability that bot reaches the origin without ever touching the $x$-axis or crossing the $x=y$ line.
This is simply wonderful as there does not seem to be a connection between the above probability and the error terms of the exponential function. Again the recurrence with the same boundary conditions as before gives us all the $p_{i,j}$'s.
We conclude the post with more terms of the error terms.
$\displaystyle\left(1+\frac{x}{n}\right)^n=e^x\left(1-\frac{x}{2}\frac{x}{n}+\left(\frac{x}{3}+\frac{x^2}{8}\right)\frac{x^2}{n^2}-\left(\frac{x}{4}+\frac{x^2}{6}+\frac{x^3}{48}\right)\frac{x^3}{n^3}+\left(\frac{x}{5}+\frac{13x^2}{72}+\frac{x^3}{24}+\frac{x^4}{384}\right)\frac{x^4}{n^4}-\cdots\right)$
Noting the linear term in $n$, I had the idea of using the generalized Binomial series to get the following alternate limit form. This is a better form of the limit expression as the resulting asymptotic series does not have linear term either in $n$ or in $x$.
$e^x=\displaystyle\lim_{n \to \infty}\left(1+\frac{x}{n}\right)^{n+x/2}$
That's all for today. Hope you enjoyed it.
Until then
Yours Aye
Me