I got asked by a friend this question; I have a coin, the probability of receiving a head by tossing is $p$ and tail $1-p$. I have to toss it $n$ times without getting $k$ heads in a row. What is the probability for this to occur?
This is the generalisation of the problem where the coins are unbiased (i.e $1/2$ chance of getting a head or a tail) and two heads don't occur in a row and the coin is tossed 10, 11.. or any number of times.
I am thinking along the lines of something like this:
If $F_n$ be the probability I can have a toss sequence of $n$ tosses meeting the requirements, then if the first coin is tails, the $n-1$ remaining tosses can meet the requirements with a probability of $F_{n-1}$, so the whole thing can be done with $(1-p)F_{n-1}$ probability . If the first $k-1$ coins are head then the $k^{th}$ one must be tails and the next $n-k$ can be done with a probability of $F_{n-k}$, so the whole thing has a probability of $p^{k-1}.(1-p).F_{n-k}$ , doing the same thing for first $k-2$ being heads(and next one a tail), for first $k-3$ being heads(and next one a tail), ...., for first $1$ being a head(and next one a tail) I get:
$F_{n} = (p^{k-1}.(1-p).F_{n-k}) + (p^{k-2}.(1-p).F_{n-k+1}) + ... + (p^1.(1-p).F_{n-2}) + (1-p).F_{n-1}$ , for $n>k$
i.e $F_{n} = (1-p) \sum_{0\le x<k} (p^x . F_{n-x}) $
I think for the base cases i.e from $F_1$ to $F_{k-1}$ all the values have a probability of $1$ since we can have any side of coin without breaking the requirement.
This is getting a bit too messy and I am not sure if it is right.. How do I go about solving this? That is get a closed form out of it. The specific unbiased coin problem has a solution in terms of fibonacci numbers(which has a closed form solution).