DEV Community

ANNA LAPUSHNER
ANNA LAPUSHNER

Posted on

ZED-Score Calculator

`# import the important packages
import pandas as pd # library used for data manipulation and analysis
import numpy as np # library used for working with arrays
import matplotlib.pyplot as plt # library for plots and visualizations
import seaborn as sns # library for visualizations
%matplotlib inline

import scipy.stats as stats # this library contains a large number of probability distributions as well as a growing library of statistical functions
# ZED score comparison

The Z-score formula is:

Z = (X - μ) / σ

Where:

Z is the Z-score

X is the individual data point

μ is the population mean

σ is the population standard deviation

x_1 = 83000
mu_1 = 77000
sigma_1 = 1100

z_1 = (x_1 - mu_1) / sigma_1
print("The Z-score is:", z_1)

x_2 = 92000
mu_2 = 59000
sigma_2 = 1300

z_2 = (x_2 - mu_2) / sigma_2
print("The Z-score is:", z_2)

Formula_A = stats.norm.cdf(z_1) - stats.norm.cdf(z_2)
print (Formula_A)

Formula_B = stats.norm.cdf(x_1,loc=mu_1,scale=sigma_1) - stats.norm.cdf(x_2,loc=mu_2,scale=sigma_2)
print (Formula_B)

`

Top comments (0)