Calculating  one-proportional Z-test using formula

In this approach, we will be calculating the one-proportional Z-test using the given formula and by simply putting the given value in the formula and getting the result.

Formula:

z=(P-Po)/sqrt(Po(1-Po)/n

In this example, we are using the P-value to 0.86, Po to 0.80, and n to 100, and by using this we will be calculating the z-test one proportional in the python programming language.

Python

import math
  
P = 0.86
Po = 0.80
n = 100
a = (P-Po)
b = Po*(1-Po)/n
z = a/math.sqrt(b)
print(z)

                    

Output:

1.4999999999999984

How to Perform a One Proportion Z-Test in Python

In this article, we will be looking at the approach to perform a one-proportion Z-test in the Python programming language. 

Z-test is a statistical test to determine whether two population means are different when the variances are known and the sample size is large.

One-proportion Z-test formula:

Where: 

  • P: Observed sample proportion
  • Po: Hypothesized Population Proportion
  • n: Sample size 

The one-proportional Z-test uses the following null hypotheses:

  • H0: p = p0 (population proportion is equal to hypothesized proportion p0)

The alternative hypothesis can be either two-tailed, left-tailed, or right-tailed:

  • H1 (two-tailed): p ≠ p0 (two-tailed population proportion is not equal to some hypothesized value p0)
  • H1 (left-tailed): p < p0 (left-tailed population proportion is less than some hypothesized value p0)
  • H1 (right-tailed): p > p0 (right-tailed population proportion is greater than some hypothesized value p0)

Similar Reads

Method 1: Calculating  one-proportional Z-test using formula

In this approach, we will be calculating the one-proportional Z-test using the given formula and by simply putting the given value in the formula and getting the result....

Method 2: Calculating  one-proportional Z-test using  proportions_ztest() function

...