Hypothesis Testing

In statistics, hypothesis testing is a form of inference using data to draw certain conclusions about the population. First, we make an assumption about the population which is known as the Null Hypothesis. It is denoted by H₀. Then we define the Alternate Hypothesis which is the opposite of what is stated in the Null Hypothesis, denoted by Hₐ. After defining both the Null Hypothesis and Alternate Hypothesis we perform what is known as a hypothesis test to either accept or reject the Null Hypothesis. If the sample obtained from the data or any event has the probability of occurrence less than a pre-defined probability known as the significance level (denote by α) then we reject the Null Hypothesis saying that the sample or the event has not occurred by chance but rather is statistically significant.

Let’s understand this with a real-world example, let us take a case of a courtroom battle, where a defendant is brought in front of the judge for trial. Here, the initial assumption is that the defendant is innocent (because the law books state that the accused is innocent until proven guilty). So, here our null hypothesis becomes that the accused is innocent. Next, we define the alternate hypothesis which is…, yes! you guessed it right. The accused is guilty or not innocent. Next, the lawyers start gathering evidence to prove that the accused is guilty. If the judge finds the evidence against the accused significant then the accused is declared guilty or in other statistical terms, we can say that the null hypothesis is rejected.

There are three major types of Hypothesis Testing:

  1. Comparison of Means
  2. Comparison of proportions
  3. Test of independence.

In this article, I will try to cover the Comparison of Means first, theoretically, and then will implement the same on the Golf Ball dataset. But first, let’s jot down the steps for hypothesis testing and finding statistical inference.

  1. State the Null Hypothesis.
  2. State the Alternate Hypothesis.
  3. Define a significance level.
  4. Calculate the test statistic and the corresponding p-value.
  5. Draw Conclusion from the test.

Below, I explain all these steps with the help of a real-world use case. You can find the dataset here.

So, the problem statement here is,

Par Inc., is a major manufacturer of golf equipment. Management believes that Par’s market share could be increased with the introduction of a cut-resistant, longer-lasting golf ball. Therefore, the research group at Par has been investigating a new golf ball coating designed to resist cuts and provide a more durable ball. The tests with the coating have been promising. One of the researchers voiced concern about the effect of the new coating on driving distances. Par would like the new cut-resistant ball to offer driving distances comparable to those of the current-model golf ball. To compare the driving distances for the two balls, 40 balls of both the new and current models were subjected to distance tests. The testing was performed with a mechanical hitting machine so that any difference between the mean distances for the two models could be attributed to a difference in the design. Source

From the above-given information and the dataset we have to answer the following questions:

1. Formulate and present the rationale for a hypothesis test that par
could use to compare the driving distances of the current and new
golf balls

2. Analyze the data to provide the hypothesis testing conclusion. What
is the 
p-value for your test? What is your recommendation for Par

The first step involves stating the Null Hypothesis. In the above use case, the null hypothesis would be “There is no effect of new coating on the driving distance of the ball.”

The second step involves stating the Alternate Hypothesis. The Alternate Hypothesis in the above use case is “There is some effect of new coating on the driving distance of the ball.”

The third step is defining the significance value. The significance level, also known as alpha or α, is a measure of the strength of the evidence that must be present in your sample before you will reject the null hypothesis and conclude that the effect is statistically significant. It is calculated as 1-confidence coefficient (confidence coefficient is confidence level divided by 100). Hence, if we consider a confidence level of 95% then the significance value will be 0.05.

The fourth step is calculating the test statistic and the corresponding p-value. A test statistic is a value calculated using a statistical test with which we can obtain a p-value, the p-value is the probability of obtaining results at least as extreme as the observed results of a statistical hypothesis test, assuming that the null hypothesis is correct. For further information on p-value please refer to this page. The following code snippet demonstrates the implementation of the t-test in python.

For an in-depth intuition of the t-test please refer to the following article.

The fifth step is drawing inferences from the test statistic and the p-value. The p-value obtained from the test is 0.1879 which is greater than 0.05. Hence we cannot reject the Null Hypothesis.

For the entire analysis and code please refer to my Kaggle Notebook on the Golf Ball Dataset.


  1. https://statisticsbyjim.com/glossary/significance-level/
  2. https://www.statisticshowto.com/confidence-level/
  3. https://towardsdatascience.com/the-statistical-analysis-t-test-explained-for-beginners-and-experts-fd0e358bbb62
  4. https://www.investopedia.com/terms/p/p-value.asp

One response to “Hypothesis Testing”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: