ethanweed / pythonbook

Python adaptation of Danielle Navarro's Learning Statistics with R (http://learningstatisticswithr.com/). Work in progress!
100 stars 34 forks source link

https://ethanweed.github.io/pythonbook/03.01-descriptives.html#mean-absolute-deviation #32

Closed bbishop423 closed 5 months ago

bbishop423 commented 7 months ago

Correcting variable naming in python code:

from statistics import mean

X = [56, 31, 56, 8, 32] # 1. enter the data X_bar = mean(X) # 2. find the mean of the data AD = [] # 3. find the absolute value of the difference between for i in X: # each value and the mean and add it to the list AD
AD.append(abs((i-X_bar)))
AAD = mean(AD) # 4. find the mean of the absolute values print(AAD)