Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. from statistics import mean, stdev
  2. import matplotlib
  3. import numpy as np
  4. import matplotlib.pyplot as plt
  5.  
  6. obsList = [3.7, 4.2, 4.4, 4.4, 4.3, 4.2, 4.4, 4.8, 4.9, 4.4,
  7. 4.2, 3.8, 4.2, 4.4, 4.6, 3.9, 4.3, 4.5, 4.8, 3.9,
  8. 4.7, 4.2, 4.2, 4.8, 4.5, 3.6, 4.1, 4.3, 3.9, 4.2,
  9. 4.0, 4.2, 4.0, 4.5, 4.4, 4.1, 4.0, 4.0, 3.8, 4.6,
  10. 4.9, 3.8, 4.3, 4.3, 3.9, 3.8, 4.7, 3.9, 4.0, 4.2,
  11. 4.3, 4.7, 4.1, 4.0, 4.6, 4.4, 4.6, 4.4, 4.9, 4.4,
  12. 4.0, 3.9, 4.5, 4.3, 3.8, 4.1, 4.3, 4.2, 4.5, 4.4,
  13. 4.2, 4.7, 3.8, 4.5, 4.0, 4.2, 4.1, 4.0, 4.7, 4.1,
  14. 4.7, 4.1, 4.8, 4.1, 4.3, 4.7, 4.2, 4.1, 4.4, 4.8,
  15. 4.1, 4.9, 4.3, 4.4, 4.4, 4.3, 4.6, 4.5, 4.6, 4.0]
  16. xBar = mean(obsList)
  17. stdDev = stdev(obsList)
  18. fig, ax = plt.subplots()
  19. n,bins,patches = ax.hist(obsList,bins="auto",density=True)
  20. y = ((1 / (np.sqrt(2 * np.pi) * stdDev)) *
  21. np.exp(-0.5 * (1 / stdDev * (bins - xBar))**2))
  22. ax.plot(bins,y,"--")
  23. ax.set_xlabel("Weight - grams")
  24. ax.set_ylabel("Probability")
  25. fig.tight_layout()
  26. plt.show()'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement