2
$\begingroup$

Suppose, I toss a fair coin n = 10 times and get 7 heads and 3 tails. The probability of fair coin is p = 0.5. Now, that the beta distribution is a conjugate prior of the binomial likelihood. I used the probability density function equation for beta distribution, as given in Wikipedia (https://en.wikipedia.org/wiki/Beta_distribution). I can't seem to understand what values of alpha and beta should I use. The alpha - 1 is the number of heads and beta - 1 is the number of tails. Now assuming a uniform prior distribution U(0,1) or Beta(1,1). I calculate the posterior probability as 1. Is my answer right?.

And what will be the solution if my coin is biased, suppose p = 0.7 (instead of p = 0.5).

$\endgroup$
2
  • $\begingroup$ "I calculate the posterior probability as 1" The posterior probability of what? It seems like you computed the probability density around $p=0.5$ and not the probability of $p=0.5$. $\endgroup$ Commented Dec 8, 2023 at 20:19
  • 1
    $\begingroup$ "The probability of fair coin is p = 0.5" It is unclear what you mean with this. The value 0.5 is the probability that you have a fair coin? Or is $p=0.5$ referring to the probability parameter of the Bernoulli distribution for heads and tails? $\endgroup$ Commented Dec 8, 2023 at 20:21

2 Answers 2

6
$\begingroup$

First of all, you already know the coin is fair hence the next throw will have a 50% chance of head and 50% of tail. If you know the coin is fair, the posterior distribution is p = 0.5.

Now, what if you do not know if the coin is fair or not fair and you only see a sequence of 7 heads and 3 tails. Assume Head = 1 and Tail = 0.

Then you can use a prior of beta (1,1). This means you start believing the coin is fair. Then you see the draws, you update the binomial. Look online this is a conjugate distribution and the posterior will be Beta(1 + 7, 1 + 3). The mean is 8/12 = 0.66. Is states that your prior belief that the coin is fair was slightly tilted toward a biased coin favoring heads. Note you start believing 0.5, you see 0.7 in the data and you end up updating to a 0.66.

$\endgroup$
4
  • $\begingroup$ How can I solve Beta(1 + 7, 1 + 3) in R. Can I just use the function 'beta()' function to get the answer. I get beta(8,4) = 0.0007575758. Does this mean that the posterior is 0???? $\endgroup$ Commented Dec 9, 2023 at 2:29
  • $\begingroup$ I don't know this function, you should look at the documentation. It may be one draw from a beta(8,4). If you make 10k draws and compute the mean you will get the posterior mean of 0.66. The mean is just one information, you have the whole posterior distribution, it follows a beta(8,4). You can calculate for example how likely p is in the range 0.5 and 0.8. Please accept the answer to your original question $\endgroup$ Commented Dec 10, 2023 at 13:11
  • 2
    $\begingroup$ A prior of $\operatorname{Beta}(1,1)$ doesn't mean you start believing the coin is fair. It says you start considering any weighting of the coin to be equally likely. So you wouldn't be surprised if it always came up heads, always came up tails, or came up heads $72\%$ of the time. These would all seem reasonable to you. Coming in with a prior of $\operatorname{Beta}(n,n)$ for $n>1$ says that you consider it more likely for the coin to be close to fair than not. The larger $n$ is, the greater your confidence. $\endgroup$ Commented Feb 16 at 16:25
  • $\begingroup$ Absolutely correct, thank you for pointing that out! $\endgroup$ Commented Feb 28 at 22:39
0
$\begingroup$

The question is itself ambiguous, as many already claimed.

Usually, we use bayesian analysis to find which values of $\theta$ can give as an output the observed result ($X$, or the simulations you observed. In this case, the 7 heads and 3 tails.).

So, from basics, posterior is proportional to Likelihood times Prior.

$$\pi(\theta | X) \propto L(X|\theta) \cdot P(\theta)$$

Theta is the parameter you 'do not know' (in this case, the probability that the coin is fair). As such $\pi(\theta | X)$ is the 'posterior' probability conditional on the observed data and your prior beliefs.

$L(X|\theta)$ is then the likelihood of observing those 7 heads and 3 tails ($X$, or the observations) for each possible value of $\theta$. For your example, you should iterate over all possible values of $\theta$ (representing the possible real probabilities of the coin) and calculate the probability of observing $X$:

Likelihood of theta, given X

This is the Likelihood for each possible value of $\theta$, so, $\binom{10}{7} \cdot \theta ^ {7} \cdot (1 - \theta) ^ {3}$

Then, the prior is a Beta distribution, which should consider your beliefs about the coin.

as @Tomas already said, you can use a prior of beta(1,1) but it represents a uniform distribution over $\theta$, and not any particular belief about the location (as if you had no clue of what's the probability of the coin). Also notice that it is highly misleading to talk about those 0.5 and 0.7, since the 0.7 represent the Maximum Likelihood Estimation and it is equivalent to the Mode in our Posterior Distribution with a prior Beta(1,1). The mean and the median are also used as measures of centrality, but they are not directly comparable.

Beta(1,1)

If you have a belief over the coin being fair, you can incorporate those beliefs. In example, with a Beta(3,3) (or Beta(5,5), it just modifies the strength of your belief of the prior information and your confidence around it being centered around 0.5, also, the beta distribution is always symmetric around 0.5 if $\alpha = \beta$, so you can choose any number bigger than 1 and it will express some prior beliefs around a fair coin.). The Beta(3,3) looks something like this:

Beta(3,3)

Finally, you multiply both distributions. (Using the beta(1,1) is a uniform distribution, which is basically only the likelihood, so no need to show that one again) But the Likelihood*Beta(3,3) = Beta(7+3, 3+3) = Beta(10,6) would look like this:

enter image description here

Which is just a bit more centered towards a fair coin than the Likelihood itself, but still highly weighted by your observations. Also notice that it is still a probability distribution, so the area is always 1.

You can play with the beta distribution https://homepage.divms.uiowa.edu/~mbognar/applets/beta.html

$\endgroup$
1
  • $\begingroup$ Gosh I feel I gave a sloppy answer. Great work! Thank you for sharing your thoughts on the question $\endgroup$ Commented Feb 28 at 22:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.