# NOT RUN {
x <- rnorm(4)
z <- sample(1L:10L,size = 4,replace = TRUE)
obj <- DP()
ss <- sufficientStatistics(obj = obj,x=x,foreach = TRUE)
for(i in 1L:length(x)) posterior(obj = obj,ss=ss[[i]],z=z[i])
xnew <- rnorm(10)
znew <- sample(1L:10L,size = 10,replace = TRUE)
dPosteriorPredictive(obj = obj,x=xnew,z=znew)
# }
Run the code above in your browser using DataLab