Z-Score (13)

Table of contents

Definition

A Z-score measures how far away a data point is from the average (also called the mean) of a group of data points, in units of standard deviation. Standard deviation is a way of measuring how spread out the data points are.

For example, imagine you took a test and scored 80 out of 100. If the average score for the class was 70 out of 100, and the standard deviation was 5, then your Z-score would be (80 - 70) / 5 = 2. This means that your score was 2 standard deviations above the average score for the class.

A Z-score can be positive, negative, or zero. A positive Z-score means that the data point is above the average, a negative Z-score means it's below the average, and a Z-score of zero means it's exactly equal to the average.

Formula

The formula for calculating the z-score for a given data point x, with a population mean μ and standard deviation σ, is:

z = (x - μ) / σ

where z is the z-score.

The z-score represents the number of standard deviations that the data point x is away from the population mean μ. If the z-score is positive, the data point is above the mean; if it is negative, the data point is below the mean. A z-score of 0 means the data point is exactly at the mean.

An example code in Python that calculates the z-score of a data point given the population mean and standard deviation:

def calculate_z_score(x, mu, sigma):
    z = (x - mu) / sigma
    return z

To use this function, you would pass in the value of the data point x, the population mean mu, and the population standard deviation sigma as arguments:

# example usage
x = 75
mu = 68
sigma = 5

z = calculate_z_score(x, mu, sigma)
print(f"The z-score of x={x} with mu={mu} and sigma={sigma} is {z:.2f}")

Output

The z-score of x=75 with mu=68 and sigma=5 is 1.40

That's the end of the article readers!

Will be explaining more in my following blogs!

"Statistics is the grammar of science." - Karl Pearson.

Do subscribe and keep supporting! 😊