Probability of k heads being the longest run in a row in n flips? EDIT: I miswrote the question I was trying to originally convey. Below is the correct question.
How can I use the Bernoulli distribution calculate the probability of the longest run of heads:
$0$ heads in a row in $5$ flips being the longest run
$1$ head in a row in $5$ flips  being the longest run
$2$ heads in a row in $5$ flips being the longest run
$3$ heads in a row in $5$ flips being the longest run
$4$ heads in a row in $5$ flips being the longest run
$5$ heads in a row in $5$ flips being the longest run   
Is there a specific formula that can be use when one is interested in the number of successes in a row?
Not sure if I'm approaching this correctly, but for example if I want the probability that 4 heads appears in a row in 5 flips: HHHHT and THHHH are the only possibilities? So would the probability just be 1/16? I'm looking for a formula I can use.
 A: Maximum run of zero heads:  The only way this can occur is if all five flips are tails.  For a fair coin, this has probability
$$\left(\frac{1}{2}\right)^5 = \frac{1}{32}$$
of occurring.
Maximum run of one head:  For this to occur, there must either be one, two, or three heads in the sequence, no two of which are consecutive.
One head in the sequence:  There are five positions in which the only head could occur.  For a fair coin, this occurs with probability
$$\binom{5}{1}\left(\frac{1}{2}\right)^5 = \frac{5}{32}$$
Two heads in the sequence, with the two heads not occurring consecutively:  This can occur in six ways.  Let's see why.  Line up three tails in a row, which creates four spaces, two between consecutive tails and two at the ends of the row.
$$\square T \square T \square T \square$$
To ensure that no two heads are consecutive, choose two of these four spaces in which to place a head.  For instance, choosing the first and third spaces yields the sequence 
$$HTTHT$$
The number of ways we can choose two of the four spaces is 
$$\binom{4}{2} = 6$$
The actual sequences are HTHTT, HTTHT, HTTTH, THTHT, THTTH, TTHTH.  For a fair coin, the probability of having a maximum run of one head if there are two heads in the sequence is 
$$\binom{4}{2}\left(\frac{1}{2}\right)^5 = \frac{6}{32} = \frac{3}{16}$$
Three heads in the sequence, with no two of the heads occurring consecutively:  This can occur in one way: HTHTH.  For a fair coin, the probability of having a maximum run of one head if there are three heads in the sequence is
$$\left(\frac{1}{2}\right)^5 = \frac{1}{32}$$
Since these three cases are mutually exclusive and exhaustive, the probability that the maximum run has one head is
$$\frac{5}{32} + \frac{3}{16} + \frac{1}{32} = \frac{12}{32} = \frac{3}{8}$$ 
Maximum run of two heads:  For this to occur, either two, three, or four heads must occur in the sequence, with no more than two being consecutive.
Two heads occur in the sequence and they are consecutive:  The run of two heads must begin in one of the first four positions in the sequence, resulting in one of the sequences HHTTT, THHTT, TTHHT, TTTHH.  For a fair coin, this occurs with probability
$$\binom{4}{1}\left(\frac{1}{2}\right)^5 = \frac{4}{32} = \frac{1}{8}$$
Three heads occur in the sequence, with exactly two being consecutive:  Place two tails in a row.  This creates three spaces, one between the two tails and two at the ends of the row.
$$\square T \square T \square$$
Choose one of these three spaces for the pair of consecutive heads.  Choose one of the remaining two spaces for the remaining head.  For instance, if we choose the third space for the pair of consecutive heads and the first space for the single head, we get the sequence 
$$HTTHH$$
The number of such sequences is $3 \cdot 2 = 6$.  For a fair coin, this occurs with probability
$$\binom{3}{1}\binom{2}{1}\left(\frac{1}{2}\right)^5 = \frac{6}{32} = \frac{3}{16}$$
The actual sequences are HHTHT, HHTTH, HTHHT, HTTHH, THHTH, THTHH.
Four heads occur in the sequence, with no more than two being consecutive:  This can occur in one way: HHTHH. For a fair coin, this has probability
$$\left(\frac{1}{2}\right)^5 = \frac{1}{32}$$
of occurring.
Since these three cases are mutually exclusive and exhaustive, the probability of a maximum run of two heads occurring is 
$$\frac{1}{8} + \frac{3}{16} + \frac{1}{32} = \frac{11}{32}$$
Maximum run of three heads:  For this to occur, there must either be three heads or four heads, with exactly three of the heads being consecutive.
Exactly three heads occur, with all of them being consecutive:  The first head must occur in one of the first three tosses, giving HHHTT, THHHT, or TTHHH.  For a fair coin, this occurs with probability
$$3\left(\frac{1}{2}\right)^5 = \frac{3}{32}$$
Four heads occur, with exactly three of them being consecutive:  This can occur in two ways: HHHTH or HTHHH.  For a fair coin, this occurs with probability
$$2\left(\frac{1}{2}\right)^5 = \frac{1}{16}$$
Since the two possible cases are mutually exclusive and exhaustive, the probability that the maximum run of heads has length $3$ is 
$$\frac{3}{32} + \frac{1}{16} = \frac{5}{32}$$ 
Maximum run of four heads: This can occur in two ways:  $HHHHT$ or $THHHH$.  For a fair coin, this has probability
$$2\left(\frac{1}{2}\right)^5 = \frac{2}{32} = \frac{1}{16}$$
of occurring, as you found.
Maximum run of five heads: The only way this can occur is if all five flips are heads.  For a fair coin, this has probability
$$\left(\frac{1}{2}\right)^5 = \frac{1}{32}$$
of occurring.
Check:  Since the maximum run of heads must have length $0$, $1$, $2$, $3$, $4$, or $5$, the probabilities should add to $1$.
$$\frac{1}{32} + \frac{3}{8} + \frac{11}{32} + \frac{5}{32} + \frac{1}{16} + \frac{1}{32} = 1$$
A: Your problem is poorly stated.  For the sequence $HHHTH$ does that count as getting $1$ head in a row (the last one)?  Please clarify.

Here is the answer if "getting $k$ in a row" means that the longest sequence in a row has $k$ elements, but might occur more than once.  (Thus $HHTHH$ counts as having $2$ heads in a row.)
The probability of getting and particular sequence of heads and tails is $\left( \frac{1}{2}\right)^5$, of course.
So the question reduces to:  How many ways can we get a sequence with the given criteria?  (Then multiply this by $\left( \frac{1}{2}\right)^5$.)


*

*To get at most $0$ heads in a row, there is $1$ way.

*To get at most $1$ head in a row, there are $7$ ways.

*To get at most $2$ heads in a row, there are $4$ ways.  

*To get at most $3$ heads in a row, there are $5$ ways.

*To get at most $4$ heads in a row, there are $2$ ways.

*To get at most $5$ heads in a row, there is $1$ way.

