Terms related to variability metrics:
-" Deviation -" Variance -" Standard Deviation -" Mean Absolute Deviation -" Meadian Absolute Deviation -" Order Statistics -" Range -" Percentile -" Inter-quartile Range
- Deviation: we can call it — errors or leftovers too. It is a measure of how different / scattered the values are from the central / observed value.
Example:Sequence: [2, 3, 5, 6, 7, 9] Suppose, Central / Observed Value = 7 Deviation = [-5, -4, -2 , -1, 0, 2]
- Variance (with 2 ): This is the most famous measure for assessing variability because it represents is the squared deviation. This can be called the root mean square error, because it is the mean of the standard deviation.
Example:
Sequence: [2, 3, 5, 6, 7, 9] Mean = 5.33 Total Terms, n = 6 Squared Deviation = (2 - 5.33) 2 + (3 - 5.33) 2 + (5 - 5.33) 2 (6 - 5.33) 2 + (7 - 5.33) 2 + (9 - 5.33) 2 Variance = Squared Deviation / n
Code —
# Dispersion
import
numpy as np
Sequence
=
[
2
,
3
,
5
,
6
,
7
,
9
]
var
=
np.var (Sequence)
print
(
"Variance:"
, var)
Output:
Variance: 5.5555555555555545
- Standard Deviation: is the square root of the variance. Also referred to as Euclidean norm .
Example:
Sequence: [2, 3, 5, 6, 7, 9] Mean = 5.33 Total Terms, n = 6 Squared Deviation = (2 - 5.33) 2 + (3 - 5.33) 2 + (5 - 5.33) 2 (6 - 5.33) 2 + (7 - 5.33) 2 + (9 - 5.33) 2 Variance = Squared Deviation / n Standard Deviation = (Variance) 1/2
Code —
# Standard deviation
import
numpy as np
Sequence
=
[
2
,
3
,
5
,
6
,
7
,
9
]
std
=
np.std (Sequence)
print
(
"Standard Deviation:"
, std)
Output:
Standard Deviation: 2.357022603955158
- Average absolute deviation: you can estimate the typical estimate of these deviations. If we average the values, negative deviations will displace positive ones. Also, the sum of deviations from the mean is always zero. Thus, this is a simple approach for averaging the deviation itself.
Example:
Sequence: [2, 4, 6, 8] Mean = 5 Deviation around mean = [-3, -1, 1, 3] Mean Absolute Deviation = (3 + 1 + 1 + 3) / 4
# Average Absolute Deviation
import
numpy as np
def
mad (data):
return
np. mean (np.absolute (
data
-
np. mean (data)))
Sequence
=
[
2
,
4
,
6
,
8
]
print
(
"Mean Absolute Deviation: "
, mad (Sequence))
Output:
Mean Absolute Deviation: 2.0