Menu

Coefficient of Variation in Python, JavaScript, R, SQL, and Rust
📰

Coefficient of Variation in Python, JavaScript, R, SQL, and Rust

DEV Community: rust·Canyam Ai·4 days ago
#LRitPyFr
#devtorust#devto#dev#mean#standard
Reading 0:00
15s threshold

Say you’re monitoring two services. One has an average response time of 40 ms with a standard deviation of 8 ms. The other averages 900 ms with a standard deviation of 90 ms. Which one is less consistent?

By raw standard deviation, the second service looks worse. But 90 ms on a 900 ms average is a much smaller wobble than 8 ms on a 40 ms average. The coefficient of variation (CV) makes that comparison fair.

THE FORMULA

CV = (standard deviation / mean) x 100

It expresses spread as a percentage of the mean. Because the units cancel, you can compare latency to memory usage to revenue without conversions.

In the example above:

Service A: 8 / 40 = 20%

Service B: 90 / 900 = 10%

Service B is steadier relative to its own average, even though its absolute spread is larger.

SAME CALCULATION, FIVE LANGUAGES

Take the dataset 10, 12, 14, 16, 18. The mean is 14 and the sample standard deviation is about 3.16, so the CV comes out near 22.6%.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.