Following the idea of your derivation: let $t_i$ be $1$ if a run of heads starts at coin number $i$ ($i=1 \cdots n$), $0$ otherwise. Then $X_n = \sum_{i=1}^n t_i$ and
$$
P(t_i=1)=E(t_i)=
\begin{cases}
p & \text{if $i=1$} \\
p(1-p) & \text{otherwise} \\
\end{cases}
$$
The vars $t_i$ are not independent, but $E(X_n)=\sum E(t_i) = p + (n-1)p (1-p)$ as you already found. Now let's compute
$$E(X^2_n)= E\left[\left(\sum t_i \right)^2\right]=\sum_{i=1}^n\sum_{j=1}^n E(t_i t_j)$$
The terms of the sum can be grouped in:
A) $i=j$: (with $n$ terms) $E(t_i t_j)=E(t_i^2)=E(t_i)$. The sum over these terms is $p + (n-1)p (1-p)$.
B) $|i-j|=1$: (with $2 \times (n-1)$ terms). Here one of the two must be zero,so $E(t_i t_j)=0$
In the remainder, the variables $t_i,t_j$ are independent. Hence
C) $|i-j|>1$ and $i=1$ or $j=1$ : (with $2\times(n-2)$ terms) $E(t_i t_j) = p^2(1-p)$
D) $|i-j|>1$ and $i>1$ and $j>1$ : (with $n^2-5n +6$ terms) $E(t_i t_j) = p^2(1-p)^2$
Finally
$$E(X_n^2)=p+\left( n-1\right) \,\left( p-1\right) \,p+ 2\,\left( n-2\right) \,\left( 1-p\right) \,{p}^{2}+\left( {n}^{2}-5\,n+6\right) \,{\left( 1-p\right) }^{2}\,{p}^{2}$$
$$Var(X_n) = E(X_n^2) - E(X_n)^2 = \left( 1-p\right) \,p\,\left( 3\,n\,{p}^{2}-5\,{p}^{2}- 3 \, n\,p+3 p+n\right)=\\
=\left( 1-p\right) \,p\,\left[ n\,\left( 3\,{p}^{2}-3\,p+1\right) -p\,\left( 5\,p-3\right) \right]$$
As pointed out by Did in a comment, this is valid for $n\ge 4$; if $n<4$ the group D vanishes; if $n\le 2$, only case A survives. Then
$$Var(X_1)=p(1-p) \hspace{9pt} Var(X_2)=p(1-p)^2(2-p)\hspace{9pt} Var(X_3)=p(1-p)^2(4p^2-6p+3)$$
Best Answer
Since each fair/unfair coin toss is a bernoulli trial with parameter
P
, the question of is really asking for the Cumulative distribution function of a Binomial distribution.For instance, if we wanted to know what the chance of getting at least 10 heads in 100 flips where the probability of getting heads is 0.4 ($P(X \ge 10)$ where $X \sim Bin(100,0.4)$)
Using the formula given in the link we get a number extremely close to 1. Or use a calculator such as this to get
$P(X \ge 10) > 0.999999 $
For more info see this question.
A precise answer thanks to Henry in the comments
$P(X\ge 10)=1-P(X\le 9) = 1- \sum\limits_{k=0}^9{100 \choose k}0.6^k0.4^{100-k}\approx 1 - 1.256\times 10^{-26}$