Skip to main content
3 of 4
added 2 characters in body
David Marx
  • 7.1k
  • 2
  • 30
  • 46

Your prior is a full distribution, not just 10 values. If I were using a $N(5,1)$ prior, I would probably plot it by evaluating the density function at a large number of values over small increments in the neighborhood of its mode, like this:

xv = seq(0,10,.01)
plot(xv, dnorm(xv, 5, 1), type='l')

Generally, I'd be more likely to plot the posterior using a kernel density estimate than as a histogram, but the histogram certainly has its place (especially if you aren't able to sample a lot of values from the posterior). In any event, there's very little excuse to plot a simple prior like yours using a histogram since we know its shape exactly.

Regarding this question:

The output of dnorm(0:10,mean=5,sd=1) are ten values. Are these density values? Or are these probabilities?

I refer you to this answer that does a good job explaining how to interpret a pdf: http://stats.stackexchange.com/a/4223/8451

David Marx
  • 7.1k
  • 2
  • 30
  • 46