Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from statistics import mean, stdev
- import matplotlib
- import numpy as np
- import matplotlib.pyplot as plt
- obsList = [3.7, 4.2, 4.4, 4.4, 4.3, 4.2, 4.4, 4.8, 4.9, 4.4,
- 4.2, 3.8, 4.2, 4.4, 4.6, 3.9, 4.3, 4.5, 4.8, 3.9,
- 4.7, 4.2, 4.2, 4.8, 4.5, 3.6, 4.1, 4.3, 3.9, 4.2,
- 4.0, 4.2, 4.0, 4.5, 4.4, 4.1, 4.0, 4.0, 3.8, 4.6,
- 4.9, 3.8, 4.3, 4.3, 3.9, 3.8, 4.7, 3.9, 4.0, 4.2,
- 4.3, 4.7, 4.1, 4.0, 4.6, 4.4, 4.6, 4.4, 4.9, 4.4,
- 4.0, 3.9, 4.5, 4.3, 3.8, 4.1, 4.3, 4.2, 4.5, 4.4,
- 4.2, 4.7, 3.8, 4.5, 4.0, 4.2, 4.1, 4.0, 4.7, 4.1,
- 4.7, 4.1, 4.8, 4.1, 4.3, 4.7, 4.2, 4.1, 4.4, 4.8,
- 4.1, 4.9, 4.3, 4.4, 4.4, 4.3, 4.6, 4.5, 4.6, 4.0]
- xBar = mean(obsList)
- stdDev = stdev(obsList)
- fig, ax = plt.subplots()
- n,bins,patches = ax.hist(obsList,bins="auto",density=True)
- y = ((1 / (np.sqrt(2 * np.pi) * stdDev)) *
- np.exp(-0.5 * (1 / stdDev * (bins - xBar))**2))
- ax.plot(bins,y,"--")
- ax.set_xlabel("Weight - grams")
- ax.set_ylabel("Probability")
- fig.tight_layout()
- plt.show()'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement