# NOT RUN {
## generate some random Gaussian samples
x <- rGaussian(1000,mu = c(1,1),Sigma = matrix(c(1,0.5,0.5,3),2,2))
w <- runif(1000)
## add information to 'obj' then remove them one by one
obj <- GaussianNIW(gamma=list(m=c(0.2,3),k=1,v=2,S=diag(2)))
ss <- sufficientStatistics_Weighted(obj = obj,x=x,w=w,foreach = TRUE)
for(i in 1L:length(ss)) posterior(obj = obj,ss=ss[[i]])
obj
for(i in 1L:length(ss)) posteriorDiscard(obj = obj,ss=ss[[i]])
obj
## add information to 'obj' then remove them as a whole
obj <- GaussianNIW(gamma=list(m=c(0.2,3),k=1,v=2,S=diag(2)))
ssAll <- sufficientStatistics_Weighted(obj = obj,x=x,w=w,foreach = FALSE)
posterior(obj = obj,ss = ssAll)
obj
posteriorDiscard(obj = obj,ss = ssAll)
obj
# }
Run the code above in your browser using DataLab