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

enter image description here

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

enter image description here

and this guy

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

gives this figure

enter image description here

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

any clue


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.

| improve this answer | |
  • $\begingroup$ Thank you! You are so helpful! Does "horizontal resolution" mean the interval granularity between -5 and 5 along x-axis? $\endgroup$ – JJJohn Oct 16 '19 at 1:54
  • $\begingroup$ Yes, mainly I was thinking of the x axis. $\endgroup$ – Nathan Reed Oct 16 '19 at 2:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.