Why does my code generate a figure whose kurtosis looks a little higher than the one I am trying to reproduce?

this figure (fig_1) is an univariate normal distribution in 3D, the corresponding equation is in the top left hand corner

it seems that x varies from -5 to 5; sigma varies from 0 to 4.

This Python code is trying to reproduce this figure

ax = plt.figure().gca(projection='3d')
xx, yy = np.meshgrid(np.arange(-5,5,.1), np.arange(0.1,4,.1))
zz = norm.pdf(xx,0,yy)
ax.plot_surface(xx, yy, zz, alpha=.5)


and I got this figure

and this guy

zz = norm.pdf(xx,0,np.sqrt(yy))


gives this figure

which is better although the kurtosis looks a little higher than fig_1.

any clue

1 Answer

The value 's' in the original graph is the variance, which is the square of the Gaussian sigma (i.e. the scale parameter of the normal distribution). So norm.pdf(xx,0,np.sqrt(yy)) should be correct.

Note that the shape of the peak you see is very much dependent on the y value where the graph starts. Your starting point of 0.1 may be a little smaller than in the original graph, which looks like it starts at about 1/6 ~= 0.167, so you may see a narrower and taller peak for that reason. Also, the original graph doesn't quite have enough horizontal resolution to resolve the shape of the peak entirely, as you can see from how far apart the grid lines are spaced vertically on the sides of the peak.

• Thank you! You are so helpful! Does "horizontal resolution" mean the interval granularity between -5 and 5 along x-axis? Oct 16 '19 at 1:54
• Yes, mainly I was thinking of the x axis. Oct 16 '19 at 2:24