A coin $C$ is tossed $n$ times. The coin $C$ is known to have the following properties :


* Let $p\_i$ denote the probability of showing heads in the $i$-th toss, and $q\_i$ denote the probability of showing tails in the $i$ -th toss, so that $p\_i + q\_i = 1$ for all $i$,
* If the $i$ -th toss gives a heads, then $p\_{i+1} = k \cdot p\_i,$ (where $k \in (0,1]$ is a fixed real number), and $q\_{i+1} = 1- p\_i,$
* If the $i$ -th toss gives a tails, then $q\_{i+1} = \ell \cdot q\_i,$ (where $\ell \in (0,1]$ is a fixed real number), and $p\_{i+1} = 1- q\_{i+1}.$


What is the probability that the sequence of outcomes doesn't have two consecutive heads in it ?


The case when $k= \ell = 1$ simply leads us to the Fibonacci recursion, and is therefore easy to handle.



> 
> **Motivation behind considering the problem :**
> 
> 
> There are several situations where one can have either a failure or a
> success and the probabilities of success of failures change. For
> instance consider a seasonal ailment which makes its incidence in
> humans at most once each year. Now, given a person has already
> suffered from the ailment in a certain year, his / her immunity may
> change so that the probability that the person faces the ailment in
> the next year changes.
> 
> 
> 



Decaying probabilities
Building on a hint that was provided by prof. Arnab Chakraborty from Indian Statistical Institute, Kolkata, India (where I study) I am writing this answer.


Let us consider a more general problem :
suppose we have a coin $C$ which shows heads with probability $x$ and tails with probability $1-x$, and suppose $y \in [0,1].$ Let our interest be to generate a random variable $X$ which takes the value $1$ with probability $y$ and the value $0$ with probability $1-y$ using the given coin.


We first construct an unbiased coin tossing random variable (that is a binomial$(1,0.5)$ random variable).
For this we do the following : toss the coin $C$ twice. If the sequence of outcomes is $H,T$ then declare $Y=1$. Otherwise if the sequence of outcomes is $T,H$ then we declare $Y=0.$ For any other sequence of the two outcomes, we just reject those two tosses, and toss $C$ twice once more.
So, this would give us a random variable $Y \sim \text{binomial}(1,0.5).$


Next we consider the binary expression for the probability $y,$ and accordingly use the random variable $Y$ constructed above, to get a random variable $X \sim \text{binomial}(1,y).$


