🧮

Mean, Median, Mode, Percentiles

I know, basic stuff. Before diving back into exploratory data analysis (EDA) doing a little warm up.

Definition

Mean

The “average”. You add up a bunch of numbers and divide by how many numbers you have. Gets the average of them all.

Median

The middle score of a distribution. You line up the numbers in order and the one in the middle (or average of middle two).

Mode

The score that appears most frequently in and ordered list.

Percentile

Take one score. Add everything up, divide it by the score. Multiply by 100 and viola, you have a part of the whole.

Formula

Mean

Median

image

X = order the values in data set.

n = number of values in set.

Percentile

Python Code

Mean

from statistics import mean
  
def Av(lst):
    return mean(lst)
  
# Driver Code
holder = [10,20,30,40,50,60]
average = Av(holder)

print(average)
#35

Median

from statistics import median
  
list = [2,4,5,6]
med = statistics.median(list)
  
print(float(med))
#4.5

Mode

from statistics import mode
statistics.mode(["red", "blue", "blue", "red", "green", "red", "red"])
#Red

Percentile

def perc(input, numlist):
  return input / sum(numlist) * 100

perc(3,[1,2,3])
#50