159. Variance

Quantifies the spread or dispersion of a set of data points in a dataset

𝜎2=1𝑁∑𝑖=1𝑛(𝑥𝑖−𝜇)2𝑠2=1𝑛−1∑𝑖=1𝑛(𝑥𝑖−𝑥̄)2
Example
[10, 12, 13, 17, 20, 24]

Step 1: Find mean

𝑥̄=10 + 12 + 13 + 17 + 20 + 246=966=16

Step 2: Subtract the Mean and Square the result

(10−16)2=−62=36(12−16)2=−42=16(13−16)2=−32=9(17−16)2=12=1(20−16)2=42=16(24−16)2=82=64

Step 3: Calculate variance

𝑠2=36+16+9+1+16+646−1=1425=28.4