I'm having trouble with a basic hypothesis testing question that I just thought of. The question is the following: suppose you know that a certain lawnmower manufacturing company (called Company A) makes lawnmowers that run on average 300 minutes before running out of gas with a standard deviation of 30 minutes. Suppose you found a lawnmower and it only ran for 230 minutes before running out of gas. Did this lawnmower come from Company A?

Would this be a valid way to approach this problem? First, construct the 95% confidence interval $(300 - 1.96 * 30, 300 + 1.96 * 30)$. Since 230 minutes lie outside this confidence interval, then we can say that at the 95% confidence level, we reject the null hypothesis that this lawnmower comes from Company A.

Is that correct?


3 Answers 3


Regarding your approach: Confidence interval is a random interval $I$ constructed from the data that contains the unknown parameter of interest $\theta$ with specified probability $1-\alpha$, $\mathbb{P}(\theta\in I)=1-\alpha$. Your interval $(300−1.96∗30,300+1.96∗30)$ is not random, it is constructed from population parameters, so it is not really a confidence interval.

Let's try to solve the problem "from scratch." Assume that the distribution of running times is normal $\mathcal{N}(\mu, \sigma^2)$, with mean $\mu=300$ and standard deviation $\sigma=30$. Given the context of the problem, the normality assumption is reasonable (although we should keep in mind that we work under this assumption). Given the data $X=230$, our null hypothesis, the lawnmower came from Company A, can be formalized as follows: $H_0: X\sim \mathcal{N}(\mu,\sigma^2)$.

To test this hypothesis, we need to choose a statistic $s$, a function of data, with the following property: the larger $s$, the more tempting to reject the null. It seems intuitive to reject $H_0$ whenever $$s(X)=|X-\mu|$$ is large, i.e. whenever $X$ is far from the mean $\mu_0$. So, our rejection region is $$ s(X)>c. $$

How do we chose $c$? We chose $c$ to control the probability of type I error, i.e. an error of rejecting $H_0$ when it is true. To construct a test of size $\alpha$, we chose $c$ such that $$ \mathbb{P}(\mbox{Reject } H_0|H_0)=\alpha, $$ or $$ \alpha=\mathbb{P}(|X-\mu|>c \hspace{1mm}| \hspace{1mm} X\sim \mathcal{N}(\mu,\sigma^2))=\mathbb{P}\left(\left.|Z|>\frac{c}{\sigma} \right| Z\sim\mathcal{N}(0,1)\right)=2\Phi\left(-\frac{c}{\sigma}\right), $$ where $\Phi$ is the standard normal CDF. Solving this equation for $c$ yields $$ c=-\sigma\Phi^{-1}\left(\frac{\alpha}{2}\right). $$ For example, if we want to construct a test of size $\alpha=0.05$, then $c\approx58.8$. Since the value of the test statistic $s(X)=70$, our size $0.05$ test will reject the null.

Reporting the p-value is more informative then simply reporting whether the test accepts or rejects the null. Recall the the p-value is the smallest size $\alpha^*$ at which the test rejects the null. To find the p-value, we need to solve $$ s(X)=-\sigma\Phi^{-1}\left(\frac{\alpha^*}{2}\right) $$ for $\alpha^*$. The solution is $$ \mbox{p-value}\equiv \alpha^*=2\Phi\left(\frac{|X-\mu|}{\sigma}\right)\approx0.0196. $$ This p-value is small (less than the usual 0.05), and, therefore, the data provides strong evidence against the null hypothesis.

  • $\begingroup$ So what about the question "is that correct"? As I see your rejection region (c ~= 58.8) is the same as OP's rejection region ( 1.96 * 30 ). $\endgroup$
    – Michail L
    Jun 23, 2016 at 7:30
  • $\begingroup$ As a formal rule - yes, as a principal approach, no. I tried to describe how to tackle this (and many other similar) testing problems in a coherent principled way. $\endgroup$
    – Kostia
    Jun 23, 2016 at 15:46

I'll show you a dumb approach using Python ( https://www.youtube.com/watch?v=L5GVOFAYi8k ).

Let's build a normal distribution where the sample size if 1000000, the mean=300 and std=30:

distribution = [np.random.normal(300,30) for i in range(1000000)]

Let's plot the distribution along with the observation (230):

enter image description here

What is the percentage of elements of the distribution with value 230 or less?

print len([e for e in distribution if e<=observation]) / 1000000.0


This means that there is 1% of probability that a value of 230 (or smaller) belongs to our ditribution.

[Not 100% sure about this last part. Can anyone tell me if I'm right?] Since the value is smaller than 5% (p=0.05) we can say that it's very unlikely that the lawnmower comes from Company A.


I believe a better way to approach this is to use the normal distribution to create a Z-value of how far away from your hypothesis mean you are.

Let's assume that null hypothesis is as follows: company A made said lawn mower, and therefore the sample mean is close to the population mean. This make the alternative hypothesis: the lawn mower is not equal to the sample (i.e. two tailed, meaning we don't make assumptions of the value being above or below given number). Using the following formula, you get the z-statistic for testing this hypothesis.

population mean known variance

I will demonstrate how to calculate this using R (you can do the same with Z-tables, but I'm lazy).

> xbar = 300                     # sample mean
> mu0 = 230                      # population mean
> sigma = 30                     # population standard deviation
> n = 1                          # sample size
> z = (xbar−mu0)/(sigma/sqrt(n)) # formula
> z                              # z-statistic result [1] 2.333333

That leaves us with a z-statistic of 2.333333. We still need a critical value for testing however.

Using a critical level (p=0.05 significance) we need to calculate the critical values.

> alpha = .05   # significance level
> z.half.alpha = qnorm(1−alpha/2)
> c(−z.half.alpha, z.half.alpha) 
[1] −1.9600  1.9600              # critical values

Since the z value given above is not between the given values, we would conclude to reject the null hypothesis, and conclude that Company A has not made the lawn mower.

Souce: http://www.r-tutor.com/elementary-statistics/hypothesis-testing/two-tailed-test-population-mean-known-variance


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.