2.8 C
London
Friday, November 29, 2024
HomePythonProbability Distributions in PythonHow to Find the Z Critical Value in Python

How to Find the Z Critical Value in Python

Related stories

Learn About Opening an Automobile Repair Shop in India

Starting a car repair shop is quite a good...

Unlocking the Power: Embracing the Benefits of Tax-Free Investing

  Unlocking the Power: Embracing the Benefits of Tax-Free Investing For...

Income Splitting in Canada for 2023

  Income Splitting in Canada for 2023 The federal government’s expanded...

Can I Deduct Home Office Expenses on my Tax Return 2023?

Can I Deduct Home Office Expenses on my Tax...

Canadian Tax – Personal Tax Deadline 2022

  Canadian Tax – Personal Tax Deadline 2022 Resources and Tools...

Whenever you conduct a hypothesis test, you will get a test statistic as a result. To determine if the results of the hypothesis test are statistically significant, you can compare the test statistic to a Z critical value. If the absolute value of the test statistic is greater than the Z critical value, then the results of the test are statistically significant.

To find the Z critical value in Python, you can use the scipy.stats.norm.ppf() function, which uses the following syntax:

scipy.stats.norm.ppf(q)

where:

  • q: The significance level to use

The following examples illustrate how to find the Z critical value for a left-tailed test, right-tailed test, and a two-tailed test.

Left-tailed test

Suppose we want to find the Z critical value for a left-tailed test with a significance level of .05:

import scipy.stats

#find Z critical value
scipy.stats.norm.ppf(.05)

-1.64485

The Z critical value is -1.64485. Thus, if the test statistic is less than this value, the results of the test are statistically significant.

Right-tailed test

Suppose we want to find the Z critical value for a right-tailed test with a significance level of .05:

import scipy.stats

#find Z critical value
scipy.stats.norm.ppf(1-.05)

1.64485

The Z critical value is 1.64485. Thus, if the test statistic is greater than this value, the results of the test are statistically significant.

Two-tailed test

Suppose we want to find the Z critical value for a two-tailed test with a significance level of .05:

import scipy.stats

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

1.95996

Whenever you perform a two-tailed test, there will be two critical values. In this case, the Z critical values are 1.95996 and -1.95996. Thus, if the test statistic is less than -1.95996 or greater than 1.95996, the results of the test are statistically significant.

Refer to the SciPy documentation for the exact details of the norm.ppf() function.

Subscribe

- Never miss a story with notifications

- Gain full access to our premium content

- Browse free from up to 5 devices at once

Latest stories