Closed florianhartig closed 3 years ago
Something like this should work - please check carefully that this does exactly what you want to do!
library(BayesianTools)
density = function(pars){
ifelse(any(pars< 0) | any(pars > 24) | diff(pars) > 0, -Inf, 1)
# could replace 1 by 1/area to get normalized pdf, but usually this doesn't matter
}
sampler = function(n=1){
d1 = runif(n, 0,24)
d2 = runif(n, 0, 24)
for(i in 1:n){
if (d1[i] - d2[i] > 0) {
d1[i] = 24 - d1[i]
d2[i] = 24 - d2[i]
}
}
return(cbind(d1,d2))
}
x = sampler(100)
plot(x[,1], x[,2])
prior <- createPrior(density = density, sampler = sampler)
Question from a user