# How to calculate the value of √2 performing any common Probability Distribution test

I want to calculate the value of √2 but using any common probability distribution, preferably based on Bernoulli Trials.

I will perform a test in real and observe the output of the test and the output of this test should lead me to the value of √2 like as we can compute the value of π using Buffon's needle test

eg. I used a fair coin, performed many trials, observed the output, calculate PDF using this output, this output is equal to √2

I am new to Probability and ML so please keep it to the simplest and based on very common distributions.

Let $$U_i \stackrel{\text{i.i.d.}}{\sim} \text{Uniform(1, 2)}$$. I chose 1 and 2 to be the limits, because we know the square root of 2 is in [1,2]. Then compute $$\hat{x}_n=1 + \frac{1}{n}\sum_{i=1}^n \mathbf{1}(U_i^2 \le 2),$$ where $$\mathbf{1}(U^2\le 2)$$ is equal to $$1$$ if $$U^2 \le 2$$, and $$0$$ otherwise. I assume we can compute the squares of numbers, even if we don't have a routine for computing square roots. Then I take $$\hat{x}$$ to be an estimate of $$\sqrt{2}$$.
Why is $$\hat{x}_n$$ a good estimate? Well, the expected value of $$\hat{x}_n$$ is equal to $$1 + \int_1^2 \mathbf{1}(U_1^2 \le 2)\,dx = 1 + \int_1^\sqrt{2}\,dx = \sqrt{2}.$$ In fact, by the strong law of large numbers, $$\hat{x}_n$$ converges to its expectation, which is $$\sqrt{2}$$, as $$n\to\infty$$.
In a sequence of tosses of a fair coin, let $$\ b_i=1\$$ if the $$\ i^\text{th}\$$ toss is a head, or $$\ b_i=0\$$ if it is a tail, $$\ B_n = \sum_\limits{i=1}^n \frac{b_i}{2^i}\$$, and $$\ B = \sum_\limits{i=1}^\infty \frac{b_i}{2^i}\$$. The random variable $$\ B\$$ is uniformly distributed over the interval $$\ [0,1]\$$, and so $$\ \text{Prob}\left(B<\frac{1}{\sqrt{2}}\right)=\frac{1}{\sqrt{2}} \$$. Since $$\ \text{Prob}\left(B=\frac{1}{\sqrt{2}}\right)=0 \$$, then, with probability $$1$$, either $$\ B> \frac{1}{\sqrt{2}}\$$, or $$\ B<\frac{1}{\sqrt{2}}\$$. The first of these events will occur if and only if $$\ B_n^2>\frac{1}{2}\$$ for some $$\ n\$$, and the second will occur if and only if $$\ \left(B_n+\frac{1}{2^n}\right)^2 <\frac{1}{2}\$$ for some $$\ n\$$.
Thus, if you keep tossing the coin until either $$\ B_n^2>\frac{1}{2}\$$ or $$\ \left(B_n+\frac{1}{2^n}\right)^2<\frac{1}{2}\$$ (which will eventually occur for some $$\ n\$$ with probability $$1$$), and put $$\ X_1=0\$$ in the first case, or $$\ X_1=1\$$ in the second, then $$\ X_1=\mathbf{1}_{\left\{B<\frac{1}{\sqrt{2}}\right\}}\$$, and $$\ E\left(X_1\right)=\frac{1}{\sqrt{2}}\$$.
Now repeat the process to obtain a sequence, $$\ X_1, X_2, \dots\$$ of independent random variables with mean $$\ \frac{1}{\sqrt{2}}\$$. By the law of large numbers, $$\ \lim_\limits{n\rightarrow\infty}\frac{2}{n}\sum_\limits{i=1}^n X_i=\sqrt{2}\$$.