from numpy import linspace
from scipy.stats import norm
from matplotlib import pyplot
X = linspace(-3, 3, 100)
Y = norm.pdf(X)
pyplot.plot(X, Y)
pyplot.savefig("gaussian-dist.png")
pyplot.close()
The output plot will look like the following:

As we discussed, the norm.pdf() function, by default, takes mu to be 0 and sigma to be 1. But we can change the mu and sigma values in the following way:
from numpy import linspace
from scipy.stats import norm
from matplotlib import pyplot
X2 = linspace(5, 15, 100)
Y2 = norm.pdf(X2, loc=10, scale=2)
pyplot.plot(X2, Y2)
pyplot.savefig("gaussian-dist-2.png")
pyplot.close()
Here, the loc parameter in the norm.pdf() function indicates the mu value, and the scale indicates the sigma.








































0 Comments