150. 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

(1016)2=−62=36(1216)2=−42=16(1316)2=−32=9(1716)2=12=1(2016)2=42=16(2416)2=82=64

Step 3: Calculate variance

𝑠2=36+16+9+1+16+6461=1425=28.4