Skip to content
Prev 30852 / 398506 Next

superimposing graphs

Dirk Eddelbuettel <edd at debian.org> writes:
(The scripts are in the ISwR package, though... End of Section 1.3 and
beginning of 1.4.) The basic principle is this

h <- hist(x, plot=F)
ylim <- range(0, h$density, dnorm(0))
hist(x, freq=F, ylim=ylim)
curve(dnorm(x), add=T)

The main point is to keep both the histogram and the curve on scale,
so it does rely on knowing that the max of the normal density is at
the mean. For an empirical density, you'll have to find its maximum
empirically, but otherwise the same technique applies.