Tsallaka zuwa abun ciki
Justice Tech School

Weighted Averages

average supports weights. Use it for grades or price indexes.

Example
scores = np.array([80, 90, 70])
w = np.array([0.5, 0.3, 0.2])
print(np.average(scores, weights=w))
print(scores.mean().round(2))

Result

81.0
80.0

Exercise

Weighted mean.

np.(a, weights=w)

Quiz Test

What do weights change?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.