How to Find the Z Critical Value in Python?
Last Updated :
21 Feb, 2022
This article focuses on determining the Z-critical value in Python. When we conduct a hypothesis test, we get a test statistic as an outcome. In order to find out whether the result of the hypothesis test is statistically significant, we can compare the test statistic to a Z critical value. When the absolute value of the test statistic is larger than the Z critical value the outcome of the result is considered statistically significant.
Z critical value is a statistical term associated with the area under the standard normal model. It gives an idea about what will be the probability of any particular variable would have.
Syntax to install scipy library in python:
pip3 install scipy
Scipy is a python library used for scientific computation. It provides us scipy.stats.norm.ppf() function to compute the z-critical value.
scipy.stats.norm.ppf() function:
Syntax:
scipy.stats.norm.ppf(level)
Parameters:
level: It specifies the significance level to be used
Z-value for the left-tailed test:
In this program, we are calculating the Z critical value for a left-tailed test with a significance level of .01.
Example:
Python3
# Python program to find the z-value
# in a left-tailed test
# Importing the library
import scipy.stats
# Determine the z-critical value
scipy.stats.norm.ppf(.01)
Output:
Z-value for the left-tailed test
The Z critical value comes out to be equal to -2.326. Therefore, if the test statistic is greater than this value, then the result of the test will be considered statistically significant.
Z-value for the right-tailed test:
In this program, we are calculating the Z critical value for a right-tailed test with a significance level of .01.
Example:
Python3
# Python program to find the
# z-value in a two-tailed test
# Importing the library
import scipy.stats
# Determine the z-critical value
scipy.stats.norm.ppf(1-.01)
Output:
Z-value for the right-tailed test
The Z critical value comes out to be equal to 2.326. Therefore, if the test statistic is greater than this value, then the result of the test will be considered statistically significant.
Z-value for the two-tailed test:
In this program, we are calculating the Z critical value for a two-tailed test with a significance level of .01.
Example:
Python3
# Python program to find the z-value
# in a two-tailed test
# Importing the library
import scipy.stats
# Determine the z-critical value
scipy.stats.norm.ppf(1-.01/2)
Output:
Z-value for the two-tailed test
Note that two critical values are there when we perform the two-tailed test. The Z critical value comes out to be equal to 2.575 which means two critical values are -2.575 and 2.575. Therefore, if the test statistic is lesser than -2.575 or greater than 2.575, then the result of the test will be considered statistically significant.
Similar Reads
How to Find the F Critical Value in Python? F-critical value is a particular value that we used to compare our f value to. While conducting the F test we obtain F statistics as an outcome. For determining whether the result of the f test is statistically significant the f statistic is compared with the F critical value. If the F statistic is
2 min read
How to Find the T Critical Value in Python? To perform a T-test, we will get a test statistic as a result and determine whether the T-test results are statistically significant, we can compare the test statistic with the T critical value, if the absolute value of the test statistic is greater than the T critical value, then the test results a
2 min read
How to Find the F Critical Value in R When the F test is conducted we get the F statistic as an outcome. In order to determine whether the outcome of an F test is statistically significant or not, the F statistic is compared with an F critical value. If the F-statistic comes out to be greater than F critical value then the results of th
3 min read
How to Find Z Critical Values in R When we conduct a hypothesis test, we obtain test statistics as an outcome. Â Now in order to find out whether the outcome of the hypothesis test is statistically significant, the Z critical value is compared with the test statistic. Â If the absolute value of the test statistic comes out to be greate
3 min read
How to Find the Chi-Square Critical Value in R In this article, we are going to see how to find the Chi-Square Critical Value in R programming language.When the Chi-Square test is conducted, we get test statistics as an outcome. In order to find out whether the results of the Chi-Square are statistically significant, the test statistic is compar
2 min read
How to Find a P-Value from a Z-Score in Python? The p-value in statistics is the likelihood of getting outcomes at least as significant as the observed results of a statistical hypothesis test, given the null hypothesis is true. The p-value, rather than rejection points, is used to determine the least level of significance at which the null hypot
2 min read