# Hypothesis Testing

Every question has an answer!

- Unknown

**Hypothesis**

In any business scenario, any question can generally have two answers. Whenever we are faced with some problems, we have to make choices and to make those choices we use testing which is known as Hypothesis testing, which helps us with making decisions with a significant amount of confidence.

For e.g. what is the trend of online course subscribers?

It can be increasing or decreasing if we see the bigger picture.

A hypothesis is a claim (assertion) about a population parameter:

**Population mean:**

Example: The mean monthly cell phone bill in a particular city is Μ = $42

**Population proportion:**

Example: The proportion of adults in this city with cell phones is π = 0.88 or 88%,

In this way, we can create a different hypothesis. There are two kinds of hypotheses.

**1. Null Hypothesis H0** — It states the claim or assertion to be tested. It is always about population parameters not about a sample statistic. It represents the *status quo*.

Example: The mean diameter of a manufactured bolt is 30mm.

**2. Alternate Hypothesis H1** — This is just the opposite of the Null hypothesis. This is the hypothesis that the researchers are trying to prove. It challenges the *status quo*.

In the example above, the alternate hypothesis would be that the mean diameter of a manufactured bolt is not 30mm.

**Hypothesis Testing:**

Hypothesis testing is an approach of selecting samples from a population and using sample statistics to make judgments about the population and deciding whether a hypothesis is correct or not and based on that we reject or not reject the Null hypothesis.

Let us understand hypothesis testing with the help of an example. Suppose, we select 30 samples from a population of 300 people. The average age of the population is 45 years. Here, the null hypothesis would be

**H0: μ = 45**

We will try to compute the sample mean or the average age of the people in the sample and using that we will try to conclude whether to reject the null hypothesis or not.

To do that we will try to find the upper and lower boundaries using t or z-tests. If the sample mean falls in the rejection region (shown by the red area in the graph above), we will reject the null hypothesis otherwise, we will conclude that we fail to reject the null hypothesis and our population average age is 45 represented by H0.

There are two types of errors while doing hypothesis testing:

**Type I Error:** Reject a true null hypothesis. The probability of Type 1 error is α also known as the significance level.

**Type II Error:** Failure to reject a false null hypothesis. The probability of committing a Type II error is given by beta.

The below image shows both of the Errors. Getting confused? It is the same as the ** confusion matrix** in machine learning. All my ML geniuses will understand!

Now we come back to the testing, there are many tests available to find the confidence intervals. One should choose between the z-test and t-test based on whether the population standard deviation is known or not.

After determining the technique to be used for testing, we determine the critical values. Generally **α = 0.05** the critical z value is **±1.96** that means the critical values which determine the rejection or non-rejection of the null hypothesis. After that compute the test statistic.

Once we have computed the value of the test statistic, we will see whether it lies in the rejection region or not.

Finally, if your z-value is greater than **± 1.96**, we reject the null hypothesis.

So, this was a very brief explanation of hypothesis testing and how to use it. I believe that you would have gained some insights into the topic.

Thank you very much for reading until here. Please feel free to leave a comment if you have any feedback or suggestions. Also, let me know what would you like to read in the future and always remember “*Never stop learning”*.