add.exp.lines <- function( exp.out, i, B=10)
{
dexp.trunc <- function( u, lambda, B )
dexp(u, rate=lambda)/(1-exp(-lambda*B))
S <- dim(exp.out)[2]
I <- dim(exp.out)[3]
u <- seq(0.0001,B,length=1000)
fu <- rep(0,1000)
for (s in 1:S) fu <- fu + dexp.trunc(u,exp.out[3-i,s,I],B)/S
lines(u,fu,col="red")
invisible()
}
par(mfrow=c(3,2))
B <-10; I <- 15; S <- 500
exp.out <- exp.gibbs(B=B,I=I,S=S)
hist(exp.out[1,,I],prob=TRUE,nclass=15,xlab="u1",ylab="PDF",xlim=c(0,B),ylim=c(0,1))
add.exp.lines(exp.out,1)
hist(exp.out[2,,I],prob=TRUE,nclass=15,xlab="u2",ylab="PDF",xlim=c(0,B),ylim=c(0,1))
add.exp.lines(exp.out,2)
Run the code above in your browser using DataLab