Terms related to variability metrics:
 & gt; Deviation  & gt; Variance  & gt; Standard Deviation  & gt; Mean Absolute Deviation  & gt; Meadian Absolute Deviation  & gt; Order Statistics  & gt; Range  & gt; Percentile  & gt; Interquartile Range
Example:
Sequence: [2, 4, 6, 8] Mean = 5 Deviation around mean = [3, 1, 1, 3] Mean Absolute Deviation = (3 + 1 + 1 + 3) / 4
# Median Absolute Deviation
import
numpy as np
def
mad (data):
return
np.median (np.absolute (
data

np.median (data)))
Sequence
=
[
2
,
4
,
10
,
6
,
8
,
11
]
print
(
" Median Absolute Deviation: "
, mad (Sequence))
Output:
Median Absolute Deviation: 3.0
Sequence: [2, 30, 50, 46, 37, 91] Here, 2 and 91 are outliers Range = 91  2 = 89 Range without outliers = 50  30 = 20
Sequence: [2, 30, 50, 46, 37, 91] Sorted: [2, 30, 37, 46, 50, 91] 50th percentile = ( 37 + 46) / 2 = 41.5
Code —
# Percentile
import
numpy as np
Sequence
=
[
2
,
30
,
50
,
46
,
37
,
91
] < / code>
print
(
"50th Percentile:"
, np.percentile (Sequence,
50
))
print
(
"60th Percentile:"
, np. percentile (Sequence,
60
))
Output:
50th Percentile: 41.5 60th Percentile: 46.0
Example:
Sequence: [2, 30, 50, 46, 37, 91] Q1 (25 ^{ th percentile): 31.75 Q2 (50 th percentile): 41.5 Q3 (75 th percentile): 49 IQR = Q3  Q1 = 17.25 }
Code — 1

Output:
IQR: 17.25
Code — 2

Output:
IQR: 17.25