Mean and Weighted Mean
Copyright © 2024. All rights Reserved.
Definition of Mean
Mean is the average of a set of values. The operation is simple:
▶ Sum the values.
▶ Divide by the number of values.
Formula:
Sample mean = x̄ =
x1 + x2 + x3 + . . . + xn
n
=
n
X
i=1
xi
n
The mean shows where the ”center of gravity” lies for an observed
set of values.
Copyright © 2024. All rights Reserved.
Weighted Mean
The mean is a specific case of the weighted mean, where all
weights are equal. Formula:
Weighted mean =
(x1 · w1) + (x2 · w2) + . . . + (xn · wn)
w1 + w2 + . . . + wn
Copyright © 2024. All rights Reserved.
Example Calculation
Calculate the mean using the weighted mean formula with equal
weights of 0.2 for the sample values {1, 2, 3, 4, 5}:
Weighted mean =
(1 · 0.2) + (2 · 0.2) + (3 · 0.2) + (4 · 0.2) + (5 · 0.2)
0.2 + 0.2 + 0.2 + 0.2 + 0.2
=


0.2 · (1 + 2 + 3 + 4 + 5)


0.2 · (1 + 1 + 1 + 1 + 1)
= 3.0
Equal weights always result in the mean, as shown here.
Copyright © 2024. All rights Reserved.
Python Code
Calculating the Mean in Python:
sample = [1, 2, 3, 4, 5]
mean = sum(sample) / len(sample)
print(mean) # prints 3.0
Calculating the Weighted Mean in Python:
sample = [1, 2, 3, 4, 5]
weights = [0.2, 0.2, 0.2, 0.2, 0.2]
weighted_mean = sum(s * w for s, w in zip(sample ,
weights)) / sum(weights)
print(weighted_mean) # prints 3.0
Copyright © 2024. All rights Reserved.
Summary
▶ The mean is a simple average.
▶ The weighted mean generalizes the mean by assigning weights
to values.
▶ When weights are equal, the weighted mean equals the mean.
▶ Python provides straightforward ways to compute both.
Copyright © 2024. All rights Reserved.

Difference between Mean and Weighted Mean

  • 1.
    Mean and WeightedMean Copyright © 2024. All rights Reserved.
  • 2.
    Definition of Mean Meanis the average of a set of values. The operation is simple: ▶ Sum the values. ▶ Divide by the number of values. Formula: Sample mean = x̄ = x1 + x2 + x3 + . . . + xn n = n X i=1 xi n The mean shows where the ”center of gravity” lies for an observed set of values. Copyright © 2024. All rights Reserved.
  • 3.
    Weighted Mean The meanis a specific case of the weighted mean, where all weights are equal. Formula: Weighted mean = (x1 · w1) + (x2 · w2) + . . . + (xn · wn) w1 + w2 + . . . + wn Copyright © 2024. All rights Reserved.
  • 4.
    Example Calculation Calculate themean using the weighted mean formula with equal weights of 0.2 for the sample values {1, 2, 3, 4, 5}: Weighted mean = (1 · 0.2) + (2 · 0.2) + (3 · 0.2) + (4 · 0.2) + (5 · 0.2) 0.2 + 0.2 + 0.2 + 0.2 + 0.2 = 0.2 · (1 + 2 + 3 + 4 + 5) 0.2 · (1 + 1 + 1 + 1 + 1) = 3.0 Equal weights always result in the mean, as shown here. Copyright © 2024. All rights Reserved.
  • 5.
    Python Code Calculating theMean in Python: sample = [1, 2, 3, 4, 5] mean = sum(sample) / len(sample) print(mean) # prints 3.0 Calculating the Weighted Mean in Python: sample = [1, 2, 3, 4, 5] weights = [0.2, 0.2, 0.2, 0.2, 0.2] weighted_mean = sum(s * w for s, w in zip(sample , weights)) / sum(weights) print(weighted_mean) # prints 3.0 Copyright © 2024. All rights Reserved.
  • 6.
    Summary ▶ The meanis a simple average. ▶ The weighted mean generalizes the mean by assigning weights to values. ▶ When weights are equal, the weighted mean equals the mean. ▶ Python provides straightforward ways to compute both. Copyright © 2024. All rights Reserved.