Probabilty of a certain run in a 1000 coin flips So a run of $x$ heads has the probability $0.5^x$. 
Thefore a run of $9$ would be $0.5^9 = 0.001953125$.
But what is the chance of that run of $9$ occuring in $1000$ coinflips?
Can anyone please explain how to work this out?


Here is an answer based upon  generating functions. We start with a generating function for words of a two character alphabet $V=\{T,H\}$ which counts words with no consecutive equal characters at all.

These words are called Smirnov or Carlitz words. See example III.24 Smirnov words from Analytic Combinatorics by Philippe Flajolet and Robert Sedgewick for more information. (You might also find this answer helpful.)

The generating function $A(z)$ counting Smirnov words over a two character alphabet is according to the reference 
  \begin{align*}
  A(z)=\left(1-\frac{2z}{1+z}\right)^{-1}
  \end{align*}
The coefficient of $z^n$ of $A(z)$ gives the number of Smirnov words of length $n$, i.e. the number of words with no consecutive equal heads and tails.

Since there is no restriction to the distribution of tails, we can replace each character "T" in a Smirnov word by one or more "T"s, which means to replace
\begin{align*}
z\longrightarrow z+z^2+z^3+\cdots=\color{blue}{\frac{z}{1-z}}
\end{align*}
in the corresponding generating function $A(z)$.

Based upon $A(z)$ we obtain this way a generating function $B(z)$ with
  \begin{align*}
B(z)&=\left(1-\frac{z}{1+z}-\frac{\color{blue}{\frac{z}{1-z}}}{1+\color{blue}{\frac{z}{1-z}}}\right)^{-1}\\
&=\left(1-\frac{z}{1+z}-z\right)^{-1}\\
\end{align*}
The coefficient of $z^n$ of $B(z)$ gives the number of words of length $n$ with no consecutive equal heads.

We next allow a distribution of heads with runs up to length $8$. This implies a replacement of each character "H" by one up to eight "H"s, which means
\begin{align*}
z\longrightarrow z+z^2+z^3+\cdots+z^8=\frac{z(1-z^8)}{1-z}
\end{align*}

Based upon $B(z)$ we obtain this way a generating function $C(z)$ with
  \begin{align*}
C(z)&=\left(1-\frac{\color{blue}{\frac{z(1-z^8)}{1-z}}}{1+\color{blue}{\frac{z(1-z^8)}{1-z}}}-z\right)^{-1}\\
&=\frac{(1+z+z^2)(1+z^3+z^6)}{1-z+z^2+z^3+z^4+z^5+z^6+z^7+z^8+z^9}
\end{align*}
The coefficient of $z^n$ of $C(z)$ gives the number of words of length $n$ having no runs of heads of length $9$.

Finally in order to get the number of all words of length $n$ which have a run of heads of length $9$, we take all words and subtract those counted by $C(z)$.

We obtain
  \begin{align*}
D(z)&=\frac{1}{1-2z}-C(z)\\
&=\frac{z^9}{(1-2z)(1-z+z^2+z^3+z^4+z^5+z^6+z^7+z^8+z^9)}\\
&=z^9+3z^{10}+\color{blue}{8}z^{11}+20z^{12}+48z^{13}+112z^{14}+\cdots\tag{1}
\end{align*}
whereby the last line was obtained with some help of Wolfram Alpha.

We observe (blue marked coefficient) in (1) there are $8$ words of length $11$ having a run of (at least) $9$ consecutive heads. These are
\begin{array}{ccc}
HHHHHHHHH\color{blue}{TT}&HHHHHHHHH\color{blue}{HT}&HHHHHHHHH\color{blue}{HH}\\
\color{blue}{T}HHHHHHHHH\color{blue}{T}&HHHHHHHHH\color{blue}{TH}\\
\color{blue}{TT}HHHHHHHHH&\color{blue}{T}HHHHHHHHH\color{blue}{H}\\
&\color{blue}{HT}HHHHHHHHH\\
\end{array}

The probability of runs of heads of length $9$ in sequences of $10,100$ and $1000$ coin flips is according to WA
  \begin{align*}
2^{-10}\cdot[z^{10}]D(z)&=\frac{3}{1024}\doteq 0.00292969\\
2^{-100}\cdot[z^{100}]D(z)&\doteq 0.0875589\\
2^{-1000}\cdot[z^{1000}]D(z)&\doteq 0.624241\\
\end{align*}

