03 Median in a histogram#

%%html
<iframe width="700" height="400" src="https://www.youtube.com/embed/xTwDmnEEb9E/" frameborder="0" allowfullscreen></iframe>
import numpy as np
import pandas as pd
from pandas import Series, DataFrame
import matplotlib.pyplot as plt

khanacademy

Median in a histogram fig 1

dist = np.array(2 * [6.5] + 9 * [7] + 12 * [7.5] + 12 * [8] + 11 * [8.5] + 2 * [9] + 2 * [9.5])
bins=[0, 6, 6.5, 7, 7.5, 8, 8.5, 9, 9.5, 10]
plt.hist(dist, color='#4cb36f')
plt.xlabel('Amount of sleep (hours)')
plt.ylabel('Frequency')
plt.show()
../_images/03 Median in a histogram_7_0.png
dist.mean()
7.85
# TODO: d