How to find Z critical value in Python?

WBOY
Release: 2023-08-19 19:49:25
forward
1103 people have browsed it

How to find Z critical value in Python?

In this article, we are going to learn about how to find the Z Critical Value in Python.

What is the Z critical value?

In statistics, the area under the commonly used normal model is called the Z critical value. Shows the probability for each possible variable. When we perform a hypothesis test, what is produced is a test statistic. To determine whether the results of a hypothesis test are statistically significant, you can compare the test statistic to the Z critical value. A result is considered statistically significant when its absolute value exceeds the Z critical value. This tutorial will show you how to determine the Z critical value in Python.

When performing a hypothesis test, you will get a test statistic as the result. In order to determine whether the results of a hypothesis test are statistically significant, the test statistic needs to be compared with the Z critical value. If the absolute value of the test statistic exceeds the Z critical value, the test result is statistically significant.

grammar

In Python, you can use the scipy.stats.norm.ppf() method to get the Z critical value, the syntax is as follows −

scipy.stats.norm.ppf(q)
Copy after login

where q represents the significance level to be used.

Z critical value in Python

1. Left tail test

Suppose we want to determine the Z critical value of a left-tailed test with a significance level of 0.05 −

Example

!pip3 install scipy import scipy.stats #find Z critical value scipy.stats.norm.ppf(.05)
Copy after login

Output

-1.6448536269514729
Copy after login

The value of key value Z is -1.64485. If the test statistic is below this threshold, the test result is statistically significant.

2. Right tail test

Suppose we are looking for a Z critical value for a right-tailed test with a significance level of 0.05 −

Example

import scipy.stats #find Z critical value scipy.stats.norm.ppf(1-.05)
Copy after login

Output

1.6448536269514722
Copy after login
The key number for

Z is 1.64485. Therefore, if the test statistic is higher than this number, the test result is considered statistically significant.

3. Two-tailed test

Suppose we are looking for the Z critical value for a two-tailed test with a significance level of 0.05 -

Example

import scipy.stats #find Z critical value scipy.stats.norm.ppf(1-.05/2)
Copy after login

Output

1.959963984540054
Copy after login

There are always two essential values when you do a two-tailed test. 1.95996 and -1.95996 are the Z critical values in this situation. Therefore, the test's findings are statistically significant if the test statistic is either less than -1.95996 or more than 1.95996.

in conclusion

In statistics, the Z-critical value is used to determine insights from the data so machine learning models can use it and make predictions based on it.

The above is the detailed content of How to find Z critical value in Python?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!