# NOT RUN {
require( bmixture )
data( galaxy )
# Runing bdmcmc algorithm for the galaxy dataset
mcmc_sample = bmixnorm( data = galaxy )
summary( mcmc_sample )
plot( mcmc_sample )
print( mcmc_sample)
# simulating data from mixture of Normal with 3 components
n = 500
mean = c( 0 , 10 , 3 )
sd = c( 1 , 1 , 1 )
weight = c( 0.3, 0.5, 0.2 )
data = rmixnorm( n = n, weight = weight, mean = mean, sd = sd )
# plot for simulation data
hist( data, prob = TRUE, nclass = 30, col = "gray" )
x = seq( -20, 20, 0.05 )
densmixnorm = dmixnorm( x, weight, mean, sd )
lines( x, densmixnorm, lwd = 2 )
# Runing bdmcmc algorithm for the above simulation data set
bmixnorm.obj = bmixnorm( data, k = 3, iter = 1000 )
summary( bmixnorm.obj )
# }
Run the code above in your browser using DataLab