# Sample Proportion $\hat p$ versus $p$ as the probability of success in a Binomial Distribution

I'm new to hypothesis testing and I have a homework problem which says:

" For a certain coin test, $$H_0: P = 1/2$$ against $$H_1: P = 1/3$$ can be retained where $$P$$ represents the probability of getting a tail. To decide, this coin is tossed 4 times and $$H_0$$ is rejected only if the number of heads is 0 or 1. Find the probability of both types of errors. "

I assume this is a test for population proportion $$p$$. As per the book Understanding Basic Statistics 7E, for a test of proportion $$p$$, $$np > 5$$

where,$$n$$: sample size, $$p$$: proportion from $$H_0$$

which this question does not satisfy. Again, as per the same book, sample proportion is calculated as $$\hat p = r/n$$ where $$r$$ is the number of successes out of $$n$$ trials. But why does the solution to this homework problem use the binomial distribution to calculate the probabilities instead? How exactly are the sample proportion $$\hat p$$ and the probability of success $$p$$ in a binomial distribution related? Also, the alternative hypothesis not being a direct negation raises a question for me that whether this is a one-tailed test or a two-tailed test.

Here is the problem with its solution:

• There are errors in your (modified ?) scanned output. For example, but perhaps not least, $33/81 \ne 1/11.$ // You say the alternative is $H_1: P = 1/3,$ where $P$ is the number of Tails, but the test statistic $X$ = number of Heads has distribution $\mathsf{Binom}(4, 2/3)$ if the probability of tails is $1/3.$ // Finally, you seem to confuse the the theoretical probabilities of Heads specified by $H_0$ and $H_1$ with the estimated probability of Heads, which is $\hat P = r/n,$ for $r$ Heads in $n$ tosses in an actual experiment. // We'll need clarifications in order to be of help. Mar 27, 2020 at 22:07
• In these days when very many courses have been forced online without time for adequate planning, the confusion may not be your fault. (I have had recent personal experience with such inadequate planning.) But still, it would help a lot if you can clearly state null hypothesis, alternative hypothesis, and rejection region. Then someone can verify the Type I and II errors. Mar 27, 2020 at 22:14
• @BruceET It is one of the problems that could be in the test, and this is a picture from my guidebook which usually tends to have a lot of errors, but I have no other option than to refer to this, although I'm referring other books like the one mentioned in the question to get hold of the concepts, I don't mind the the numeric errors but would like to know if the question is fundamentally flawed. The $H_0$ not being a complement of $H_1$ and the small sample size which violates the condition $np > 5$ is what confuses me the most. Mar 29, 2020 at 15:22
• (a) It is OK (and perhaps a bit simpler in concept) to have two different specific values for $H_0$ and $H_1.$ So hypotheses OK. (b) The condition $np > 5$ is used as a rough guide to indicate that the normal distribution might give a serviceable approximation to a binomial distribution. But here I see only (attempted) exact binomial computations. So that sometimes useful rule does not apply. (c) I can't do it right now, but I'll look here again later today. If no one else has given help by then, I will try to do so--perhaps with a clearly stated similar problem and exact binomial answers. Mar 29, 2020 at 19:30

A coin may be fair or it may be biased so that $$p = P(\mathtt{Heads}) = 2/3.$$ [Notice that I've gotten rid of the possibly confusing twist of letting $$p$$ be the probability of Tails.]

We want to test $$H_0: p = 1/2$$ against $$H_1: p = 2/3.$$ [This situation in which $$H_0$$ and $$H_1$$ each specify only one value is called 'simple vs. simple'.] Data for the test will come from four tosses of the coin, with $$X =$$ the number of Heads. So the 'null distribution' of $$X$$ is $$X \sim \mathsf{Binom}(n=4, p = 1/2).$$

Intuitively, it would make sense to reject $$H_0$$ in favor of $$H_1$$ if the number of Heads is relatively large. Specifically, we reject if $$X \ge 3.$$ Then $$P(Type\; I\; Error) = \alpha = P(X \ge 3|n=4,p=1/2)$$ $$= 1-P(X\le 2|n=4,p=1/2).$$ Below we compute $$\alpha = 0.3125 = 5/16,$$ using R statistical software in which 'dbinom' is a PDF and 'pbinom' is a CDF. You should make sure you can calculate this probability from the binomial PDF--as in your picture.

sum(dbinom(3:4, 4, 1/2))
[1] 0.3125
1 - pbinom(2, 4, 1/2)
[1] 0.3125


Also, $$P(Type\; II\; Error) = \beta = P(X \le 2|n=4,p=2/3).$$

We use R again, to find $$\beta = 0.4074.$$ [This computation seems to be quite a mess in your picture. I'm not surprised that it confused you.] Sometimes, $$1 - \beta$$ is called the 'power' of such a test.

sum(dbinom(0:2, 4, 2/3))
[1] 0.4074074
pbinom(2, 4, 2/3)
[1] 0.4074074


In a practical application, it is desirable for both error probabilities $$\alpha$$ and $$\beta$$ to be smaller than in this simple example. The plot below shows the null and alternative distributions of $$X.$$ The vertical dashed line separates the Rejection and Non-rejection regions. This value is sometimes called the 'critical' value.

With only $$n = 4$$ tosses of the coin, these two distributions are not sufficiently different to make a practical test.

Now, suppose we toss the coin $$n = 100$$ times to obtain data to test $$H_0: p = 1/2$$ against $$H_1: p = 2/3.$$, rejecting $$H_0$$ if we get $$X \ge 59$$ Heads. Then

$$P(Type\; I\; Error) = \alpha = P(X \ge 59|n=100,p=1/2)$$ $$= 1-P(X\le 58|n=100,p=1/2)$$

and $$\alpha = 0.0431.$$ [Often one tries for $$\alpha \le 0.05.]$$

sum(dbinom(59:100, 100, .5))
[1] 0.04431304
1 - pbinom(58, 100, .5)
[1] 0.04431304


With 100 tosses as data, we also find that the Type II error probability $$\beta$$ is agreeably small. Specifically, $$\beta = 0.0434.$$

pbinom(58, 100, 2/3)
[1] 0.04337149


with 100 tosses of the coin, the two distributions are reasonably well separated so that both types of error can have small probabilities.

Using R, it is easy to compute $$\alpha$$ and $$\beta.$$ However, without statistical software one might use normal approximations to get useful values for these binomial probabilties. The figure below illustrates the two distributions.