Saturday, June 22, 2013

python. plotting the normal distribution in 3,2,1, ... go!

Just for reference in case I needed later or should someone find it useful, this is the shortest path I've found to graphing the normal distribution using python


#!/bin/python
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
items = []
with open('data','r') as f:
    for line in f:
        items.append(int(line))
plt.plot(items, norm.pdf(items,np.mean(items),np.std(items)))
plt.show()

1 comment:

  1. import matplotlib.pyplot as plt
    import numpy as np
    import matplotlib.mlab as mlab

    mean = 0
    variance = 1
    sigma = np.sqrt(variance)
    x = np.linspace(-3,3,100)
    plt.plot(x,mlab.normpdf(x,mean,sigma))

    plt.show()

    ReplyDelete