Change language

# Variable evaluation | set 2

Terms related to variability metrics:

` -" Deviation -" Variance -" Standard Deviation -" Mean Absolute Deviation -" Meadian Absolute Deviation -" Order Statistics -" Range -" Percentile -" Inter-quartile Range `
• Median absolute deviation: Mean absolute deviation, variance and standard deviation (discussed in the previous section) are not robust to extremes and outliers. We average the sum of the deviations from the mean -median-mode-in-python-without-libraries/">median.

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.mean -median-mode-in-python-without-libraries/">median (np.absolute ( data - np.mean -median-mode-in-python-without-libraries/">median (data)))    Sequence = [ 2 , 4 , 10 , 6 , 8 , 11 ]    print ( " Median Absolute Deviation: " , mad (Sequence))    `

` `

Output:

` Median Absolute Deviation: 3.0 `
• Statistics orders. This approach to measuring variability is based on the scatter of ranked (sorted) data.
• Range: This is the most basic measurement related to order statistics. This is the difference between the largest and smallest value in the dataset. It is useful to know the dissemination of data, but it is very sensitive to outliers. We can do this better by dropping the extremes.
Example:
` Sequence: [2, 30, 50, 46, 37, 91] Here, 2 and 91 are outliers Range = 91 - 2 = 89 Range without outliers = 50 - 30 = 20 `
• Percentile: This is a very good measure for measuring data variability while avoiding outliers. P percentile in data — is the value at which the P% values ​​or less are at least less than it, and the values ​​at least (100 — P) are greater than P.
Median — this is the 50th percentile of the data.
Example:
` 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 `
• Inter Quartile Range (IQR): works for ranked (sorted data). He has data on the division into 3 quartiles — Q1 (25- th percentile), Q2 (50- th percentile) and Q3 (75- th percentile). Interquartile range — this is the difference between Q3 and Q1.

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

 ` # Interquartile range `   ` import ` ` numpy as np ` ` from ` ` scipy.stats ` ` import ` ` iqr `   ` Sequence ` ` = ` ` [` ` 2 ` `, ` ` 30 ` `, ` ` 50 ` `, ` ` 46 ` `, ` ` 37 ` `, ` ` 91 ` `] `    ` print ` ` (` ` "IQR:" ` ` , iqr (Sequence)) `

Output:

` IQR: 17.25 `

Code — 2

 ` import ` ` numpy as np `   ` # Interquartile range ` ` iqr ` ` = ` ` np.subtract (` ` * ` ` np.percentile (Sequence, [` ` 75 ` `, ` ` 25 ` `])) `   ` print ` ` (` `" IQR: "` `, iqr) `

Output:

` IQR: 17.25 `

## Shop

Learn programming in R: courses

\$FREE

Best Python online courses for 2022

\$FREE

Best laptop for Fortnite

\$399+

Best laptop for Excel

\$

Best laptop for Solidworks

\$399+

Best laptop for Roblox

\$399+

Best computer for crypto mining

\$499+

Best laptop for Sims 4

\$

Latest questions

PythonStackOverflow

Common xlabel/ylabel for matplotlib subplots

PythonStackOverflow

Check if one list is a subset of another in Python

PythonStackOverflow

How to specify multiple return types using type-hints

PythonStackOverflow

Printing words vertically in Python

PythonStackOverflow

Python Extract words from a given string

PythonStackOverflow

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

PythonStackOverflow

Python os.path.join () method

PythonStackOverflow

Flake8: Ignore specific warning for entire file

## Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries