I'm confused as to why plot is showing such a steep curve for the gamma PDF. I thought that plotting the draws from an inverse-gamma should approximate the PDF, however it doesn't match the plotted PDF given the same parameters. I take the inverse of the rgamma()
, which makes more sense if you can see the variables I'm using. However, I've replaced variables with hard-coded values to keep my MWE brief. I am using R and my code is below:
grid <- seq(0,100,by=0.1) # hard-coded for MWE
sig.post.shape <- 91 # hard-coded for MWE
sig.post.rate <- 1247.52 # hard-coded for MWE
set.seed(1)
hist(1/rgamma(grid, shape = sig.post.shape, rate = sig.post.rate), breaks=10)
plot(grid,1/dgamma(grid, shape = sig.post.shape, rate = sig.post.rate), type = "l")
The resulting graph is: