Fix Python – How to plot normal distribution


Asked By – user1220022

Given a mean and a variance is there a simple function call which will plot a normal distribution?

Now we will see solution for issue: How to plot normal distribution


import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as stats
import math

mu = 0
variance = 1
sigma = math.sqrt(variance)
x = np.linspace(mu - 3*sigma, mu + 3*sigma, 100)
plt.plot(x, stats.norm.pdf(x, mu, sigma))

gass distro, mean is 0 variance 1

This question is answered By – unutbu

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0