# Here is an example of a trick to sample from a non- # standard distribution in WinBUGS. In this model the # data follow the Gumbel distribution with: # # f(y) = z*exp(-z)/beta, where z=exp[-(y-mu)/beta] # Mode(y) = mu # SD(y) = pi*beta/sqrt(6) model{ for(i in 1:n){ one[i]~dbern(like[i]) like[i]<- z[i]*exp(-z[i])/beta z[i]<- exp(-(y[i]-mu)/beta) } beta~dunif(0,10) mu~dnorm(0,0.1) } list(n=100, one=c(1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1), y=c(0,1,2,3,4,5,6,7,2,3, 0,1,2,3,4,5,6,7,2,3, 0,1,2,3,4,5,6,7,2,3, 0,1,2,3,4,5,6,7,2,3, 0,1,2,3,4,5,6,7,2,3, 0,1,2,3,4,5,6,7,2,3, 0,1,2,3,4,5,6,7,2,3, 0,1,2,3,4,5,6,7,2,3, 0,1,2,3,4,5,6,7,2,3, 0,1,2,3,4,5,6,7,2,3) )