Below (in R code), I'm showing a simple Bayesian R code in which I use ddistribution.name() commands (i.e., dcauchy(), dt()) to estimate what I call "x" in my code. I then plot the answers.
Coding Question:
I was wondering if I could achieve an approximately similar answer using rdistribution.name() commands (e.g., rcauchy(), rt()) to estimate what I call "x" in my code?
(P.S.: Using rdistribution.name() commands, I should then be able to histogram the answers.)
prior = function(x) dcauchy(x)
likelihood = function(x) dt(1.46, 19, x*sqrt(20))
posterior = function(x) prior(x)*likelihood(x)
plot(x <- seq(-5, 5, len = 1e4), posterior(x), col = 3)
Aucun commentaire:
Enregistrer un commentaire