# Maximizing probability of a sequence of coin tosses for a biased coin

Consider the following sequence created by flipping a biased coin five times $$D={H,H,T,H,H}$$

where H denotes heads and T denotes tails.

The probability of observing D (in the specific ordering given), assuming it was generated by flipping a coin X with an unequal probability of heads (H) and tails (H), where the distribution is:

$$P(X=H) = 0.75$$ $$P(X=T) = 0.25$$

is simply:

$$P(D) = \dfrac 3 4 \times \dfrac 34 \times \dfrac 14 \times \dfrac 34 \times \dfrac 34 = \dfrac {81}{1024}$$

However, my aim is to maximize this probability value by varying the individual $$P(X=H)$$ or in other words for what value of $$P(X=H)$$ do I maximize $$P(D)$$ ?

• new to this platform..formatted using mathjax now.. Commented Sep 5, 2020 at 4:00
• Thanks thats better and more easy to read. Commented Sep 5, 2020 at 4:01

Let $$p=\mathsf P(H)$$ and $$(1-p)=\mathsf P(T)$$.

Then we have: $$\mathsf P(D)=p^4(1-p)$$

You seek to find the value of $$p$$ that maximises the probability for $$D$$.

That is done by finding the value(s) which makes the derivative vanish and checking that this is in fact a maximum rather than a minimum or inflection. Sketching the graph helps.$$\dfrac{\mathrm d\,\mathsf P(D)}{\mathrm d\,p\hspace{4ex}}=0$$

.

The probability of $$D$$ would be $$p^h(1-p)^t$$ where $$p$$ is the probability of heads, $$h$$ is the number of heads in $$D$$, and $$t$$ is the number of tails in $$D$$. In your example $$h = 4$$ and $$t=1$$. Clearly, if $$D$$ consists of only heads, $$p = 1$$, while if $$D$$ consists of only tails, $$p = 0$$. Otherwise, we can use the derivative.

To maximize $$\mathbb{P}(D)$$, $$\frac{d}{dp} \mathbb{P}(D) = 0$$

The derivative is equal to $$(1-p)^t\frac{d}{dp}p^h + p^h \frac{d}{dp}(1-p)^t = h(1-p)^tp^{h-1} - tp^h(1-p)^{t-1} = 0$$

Solving for $$p$$ yields $$p = 0, p=1$$, and $$p = \frac{h}{h+t}$$. The $$p = 0$$ and $$p=1$$ cases will be extraneous unless $$D$$ is only heads or only tails (in which case $$\frac{h}{h+t}$$ would give the same result).