Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # normal_plot.dn.py
- import nitroplot
- import numpy as np
- mu, sigma = Cell("mu").value, Cell("sigma").value # mean and standard deviation
- s = np.random.normal(mu, sigma, Cell("samples").value)
- n = [None] * 5000
- Cell("C3").vertical = n # clear the vertical range
- Cell("C3").vertical = s # fill the range with the samples
- # Verify the mean and the variance:
- error = Cell("error").value
- abs(mu - np.mean(s)) < error
- abs(sigma - np.std(s, ddof=1)) < error
- count, bins, ignored = nitroplot.hist(s, Cell("bins").value, normed=True)
- nitroplot.plot(bins, 1/(sigma * np.sqrt(2 * np.pi)) * np.exp( - (bins - mu)**2 / (2 * sigma**2) ),linewidth=2, color='r')
- nitroplot.graph()
Advertisement
Add Comment
Please, Sign In to add comment