1
$\begingroup$

I flip a coin $n$ times, and I find that for $x$ of these it lands on heads. Let $p$ be the true probability of the coin landing on heads, though this is currently unknown.

I am interested in $P(p>0.5 \mid$ I flipped it $n$ times seeing $x$ occurrences of heads$)$.

I would really appreciate if someone could help me with:

(a) Working this probability out

(b) If there's a function in R I could use to do this (inputting the $n$ and $x$ I have for the different coins).

$\endgroup$
4
  • 2
    $\begingroup$ You need to supply at least one more piece of information: what do you currently think $p$ is and how strongly do you believe that? This information is usually encoded in a prior distribution. If you don't have such a distribution in mind, then you are probably asking the wrong question: instead, you might be looking for a hypothesis test. $\endgroup$ – whuber May 20 '20 at 15:09
  • $\begingroup$ Thanks for the quick reply! I didn't have an expected value of $p$ in mind, all I'm interested in is given I've seen $x$ out of $n$ successes, how likely it is that the value of $p$ is greater than $0.5$. I'm not sure I understand why I'm not able to work out such a probability from the information I provided. For example if I observed $n = x = 100$, I'd expect the probability that the 'true value of $p$ is larger than $0.5$' to be fairly high (though I have no idea how to actually calculate it). $\endgroup$ – lkjhgfdsa May 20 '20 at 15:23
  • 1
    $\begingroup$ Well, you have observed $p'=\frac{x}{n}$ successes. If $p'>p$, your probability is 1, else it is 0. Either way, you are done. Does this answer your question? If not, your counter-argument is the beginning of the discussion of why you need a prior probability. $\endgroup$ – Stephan Kolassa May 20 '20 at 15:27
  • $\begingroup$ Sounds like I need to read up about prior probabilities some more! For now though, given I have no further context around whether this coin is biased, the sensible thing to do seems to be to take the prior distribution to be binomial with $p=0.5$. I'll update the question to reflect this! $\endgroup$ – lkjhgfdsa May 20 '20 at 15:42
2
$\begingroup$

Well the probability that you are asking for is not computable, at least not using frequentist statistics. Observe that in general, a conditional probability is computed as

$$P(A|B)=\dfrac{P(A\cap B)}{P(B)}$$

But here, $P(B)=$ I flipped the coin n times seeing x occurrences of heads. And for this probability we would need to know the value of $p$.

You can, as sugested in the comments, consider a Bayesian perspective, but for doing that you would require knowledge on a prior distribution.

What you can actually do from a frequentist perspective is to comupte a hypothesis test. For doing this, you should define your null hypothesis: $$H_0: p=0.5$$

And the alternative hypothesis , which is:

$$H_1:p>0.5$$

Now we can compute the test statistic

$$ T = \frac{\hat{p}-p_{0}}{\sqrt{p_{0}\left(1-p_{0}\right) / n}} \sim_{a p} N(0,1) $$

where $p_0=0.5$ (the value under your null hypothesis) and $\hat{p}=x/n$ is the sample proportion. plugging in the values for $p_0$ annd $\hat{p}$, T is an actual number.

Now consider a significance level $\alpha = 0.05$ for your test. Then you can check using for example, the program R, that $z_{\alpha}=1.64$. This means that $P(N(0,1)>1.64) = 0.05$

Finally, assuming that the null hypothesis is true, T is drawn approximately from a normal distribution, so you can compare T against the value you would expect from a normal distribution, which is 1.64

  • If $T>1.64$ then T is a strange value, because it has a probability of being from a normal distribution smaller than 5%. You reached this conclusion assuming that the null hypothesis was true, so you conclude that the null hypothesis should be rejected and the alternative hypothesis should be supported.

  • If $<=1.64$ you cannot reject the null hypothesis.

Doing this in R:

n = 100 # number of tosses
x = 60 # number of heads 
p = 0.5 # your null hypothesis probability

binom.test(x=x, n=n, p=p, alternative='greater', conf.level=0.95)

Which returns

Exact binomial test

data:  x and n
number of successes = 60, number of trials = 100, p-value = 0.02844
alternative hypothesis: true probability of success is greater than 0.5
95 percent confidence interval:
  0.5129758 1.0000000
sample estimates:
  probability of success 
0.6 

So the p-value here is $0.02844$. If the p-value is smaller than $\alpha=0.05$ then you do not reject the null hypotheis. If the p-value is greater than $\alpha$ then you reject the null hypothesis

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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