Q:

Drawing a theoretical density histogram in R?

I'm wondering if it might be possible to draw a theoretical density histogram for a given continuous distribution in R? 
By a theoretical histogram, I mean a histogram that is not based on the available random variable generators in R (e.g., hist(rnorm(1e4))). Rather, a histogram that exactly matches the probability density function (pdf) of the continuous distribution in question for a user-defined support (i.e., range for the random variable) with adjustable breaks.
As an example in R, we know that the pdf of a standard normal distribution for the support -5 to 5 is theoretically shaped like obtained by the R code below. 
In R, can we turn this exact theoretical pdf to a corresponding theoritical density histogram? Any suggestion as to how this could be done in R?
c = curve(dnorm(x), -5, 5, n = 1e4)

A:

You can do a pretty good job of this with the theoretical cumulative density.  By taking the difference between the value of the cumulative distribution at either end of the region,  you get how much of the probability should be assigned to each region. These should be weighted by the width of the region. The example below uses the normal distribution.
barplot(diff(2*pnorm(c(-Inf, seq(-4,4,0.5), Inf))), ylim=c(0,0.4))

Of course, if you only have the density, not the cumulative density,  you may have to integrate. 
Note that the x-axis on the barplot is the index number of the bin, not the actual x value.  Because of this,  if you simply plot the norm density fuction over this, it will not line up. However, it is easy to make a linear shift in coordinates that will cause the pdf to line up correctly.    For this example,  the center of the distribution is at 10.9 and each bin of width 0.5 takes up 1.2 in the new scale,  so you transform the x's with (x-10.9)/2.4.  To overlay the curve, try
barplot(diff(2*pnorm(c(-Inf, seq(-4,4,0.5), Inf))), ylim=c(0,0.4))
Shifted = function(x) dnorm((x-10.9)/2.4)
curve(Shifted, 0.5,21.5, add = T) 

Sorry,  having trouble posting pictures from this machine. 

