import matplotlib
from datascience import *
%matplotlib inline
import matplotlib.pyplot as plots
import numpy as np
plots.style.use('fivethirtyeight')
There are many ways to compute the mean (average).
values = make_array(2, 3, 3, 9)
values
array([2, 3, 3, 9])
sum(values)/len(values)
4.25
np.average(values)
4.25
np.mean(values)
4.25
(2 + 3 + 3 + 9)/4
4.25
Can also be framed as a weighted average of the unique values.
2*(1/4) + 3*(2/4) + 9*(1/4)
4.25
2*0.25 + 3*0.5 + 9*0.25
4.25
values_table = Table().with_columns('value', values)
values_table
value |
---|
2 |
3 |
3 |
9 |
bins_for_display = np.arange(0.5, 10.6, 1)
values_table.ihist('value', bins = bins_for_display)