Show Menu
Cheatography

Statistics with Python Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Mean / Median

Mean = Average
np.average(array)
Median
np.median(array)
Mode
stats.mode(array)
Mean = Average
Median = Center of a dataset
Mode = Most common value in a dataset
-> (from scipy import stats)

Range

min
np.amin(data)
max
np.amax(data)
range
max - min
 

Variance

# Variance
-> Tells us how spread out the Data is

#  Variance in numpy
variance = np.var(dataset)

# Build Variance from ground up example
grades = [88, 82, 85, 84, 90]
mean = np.mean(grades)

# When calculating these variables, square the difference.
difference_one = (88 - mean) ** 2
difference_two = (82 - mean) ** 2
difference_three = (85 - mean) ** 2
difference_four = (84 - mean) ** 2
difference_five = (90 - mean) ** 2

difference_sum = difference_one  + ... + difference_five

variance = difference_sum / 5

Standard Deviation

# Standard Deviation in numpy
dataset = [4, 8, 15, 16, 23, 42]
standard_deviation = np.std(dataset)

Histogram

# Specify the Bin-Range
bin_range = (max_value - min_value + 1) / bins

# Histogram
times_hist = np.histogram(data, range = (0, 24), bins = 4)