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