How do I make plots of a 1-dimensional Gaussian distribution function using the mean and standard deviation parameter values (μ, σ) = (−1, 1), (0, 2), and (2, 3)?
I\'m n
In addition to previous answers, I recommend to first calculate the ratio in the exponent, then taking the square:
def gaussian(x,x0,sigma):
return np.exp(-np.power((x - x0)/sigma, 2.)/2.)
That way, you can also calculate the gaussian of very small or very large numbers:
In: gaussian(1e-12,5e-12,3e-12)
Out: 0.64118038842995462