A hypothesis is an assumption that must be accepted or rejected. The parametric and non-parametric tests are two types of hypothesis testing procedures. The parametric test assumes that the variables are measured on an interval scale, whereas the non-parametric test assumes that they are measured on an ordinal scale. The parametric test can now be divided into Z-test and T-test. This tutorial will teach you the difference between the Z-test and T-test.

## Hypothesis Testing

Hypothesis testing is a formal procedure for using statistics to investigate our ideas about the world. Scientists most commonly use it to test specific predictions derived from theories, referred to as hypotheses.

It's crucial to restate your initial research hypothesis as a Null and Alternate hypothesis so that you can test it mathematically.

A Null Hypothesis expresses the opposite of what a researcher or experimenter predicts or anticipates. It essentially defines the statement that no exact or actual relationship exists between the variables. It is denoted by H0.

An Alternate Hypothesis makes a statement that suggests or advises an investigator or researcher about a possible result or outcome, commonly denoted by H1.

Suppose you want to test if there is a relationship between gender and weight. Based on your knowledge, you hypothesize that males are heavier than females on average.

In this case, the Null hypothesis will be that males are not heavier than females, and the Alternate hypothesis will be that males are heavier than females.

## What Is p-Value?

The p-value is known as the probability value. P-values are used in hypothesis testing to help determine whether the null hypothesis should be rejected. The lower the p-value, the more likely the null hypothesis will be rejected.

- If the p-value is less than 0.05, the result is statistically significant. In this case, you reject the null hypothesis favoring the alternative hypothesis.
- If the p-value is greater than 0.05, then the result is not statistically significant and hence doesn't reject the null hypothesis.

## Definition of Z-Test

Z-test is the statistical test used to analyze whether two population means are different or not when the variances are known, and the sample size is large.

The z-test is based on the normal distribution.

The assumptions for Z-test are:

- All observations are independent.
- The size of the sample should be more than 30.
- The Z distribution is normal when the mean is 0, and the variance is 1.

The test statistic is defined by:

Xbar is the sample mean

σ is the population standard deviation

n is the sample size

μ is the population mean

### Example

Let's say that the mean score of students in a class is greater than 70 with a standard deviation of 10. If a sample of 50 students was selected with a mean score of 80, calculate the Z-value to check if there is enough evidence to support this claim at a 0.05 significance level.

#### Solution:

Here, the sample size is 50 and we know the standard deviation. This is a case of a right-tailed one-sample z test.

The Null hypothesis is the mean score is 70

The Alternative hypothesis is mean score is greater than 70

From the z-table, the critical value at alpha = 0.05 is 1.645

Xbar = 80

μ = 70

n = 50

σ = 10

Substituting the values in the formula, you will get the Z value to be equal to 7.09.

Since 7.09 > 1.645 thus, the null hypothesis is rejected and there is enough to support that the mean of the class is greater than 70.

## Definition Of T-Test

A T-test is a parametric test applied to identify how the average of two data sets differs when variance is not given.

When the sample size is small, and the population standard deviation is unknown, the T-test is used in conjunction with the t-distribution. The degree of freedom significantly impacts the shape of a t-distribution. The number of independent observations in a given set of observations is the degree of freedom.

There are the following assumptions taken for the T-Test:

- All the data points are independent.
- The sample size is very small.
- The sample size should be taken and recorded accurately.

Xbar is the sample mean

s is the sample standard deviation

n is the sample size

μ is the population mean

### Example:

A store wants to improve its sales. The previous sales data shows that the average sale of 30 salesmen was $40 per sale. After some training, the current data showed an average sale of $60 per transaction. If the standard deviation given is $20, find the t-value. Did training improve the sales?

#### Solution:

Xbar = 60

s = 20

n = 30

μ = 40

Substituting the values in the formula, you will get t-value = 5.47. For the alpha value of 0.05, the critical value is 1.711. Here 5.47 > 1.711, we can reject the null hypothesis and conclude that training did affect sales.

## Comparison Table Between Z-Test Vs T-Test

## Conclusion

This tutorial on the difference Z-Test vs T-Test gives you an overview of what is z-test and t-test in statistics. The tutorial also covered the formula for defining test statistics.

If you are looking to make a career as a Data Analyst, Simplilearn’s Caltech Post Graduate Program In Data Science in partnership with Purdue University and in collaboration with IBM is the program for you.

If you have any doubts or questions, please mention them in the comments section, and we'll have our experts answer them for you.