Sylvain
Sylvain

Reputation: 253

trouble with normal distribution

I have code to plot a gaussian distribution but it is not centered on 0 as it should be:

def gaussn(x):
    return 1/(np.sqrt(2*np.pi))*np.exp(-0.5*x**2)

X=np.linspace(-5,5)
GAUS=gaussn(X)
plt.plot(GAUS)

Why it is centered on 25 and not 0?

Upvotes: 1

Views: 52

Answers (1)

Rick M
Rick M

Reputation: 1012

Try plt.plot(X,GAUS) instead. By not specifying the x-axis, it's just running from 0 to 50 (i.e., the length of the array).

Upvotes: 2

Related Questions