Reputation: 4558
I have a density function f, and I do MCMC sampling for it. To evaluate the goodness of the sampling, I need to plot the hist
and curve
within the same chart. The problem of
hist(samples);
curve(dfun,add=TRUE);
is that they are on the different scale: the frequency of a certain bin is usually hundreds, while the maximum of a density function is about 1 or so. What I want to do is to configure two plots at the same height, with one y-axis on the left and the other on the right. Can anyone help? Thank you.
Upvotes: 3
Views: 5207
Reputation: 368181
Use the prob=TRUE
argument to hist
:
hist(samples, prob=TRUE)
curve(dfun,add=TRUE)
Also see this SO question
Upvotes: 7