Simple S-Plus code for Gibbs sampling analysis of a two-component normal mixture with known variance and one component centred at zero, the other having a positive mean.

# Simulate a simple normal mixture, one mean zero and known variance # Plot resulting histogram and overlay density curve

# Gibbs sampling for inference in above problem

# plot MCMC iterations at start to check convergence

# Drop first nit draws for "burn-in" of MCMC and summarise the rest

# histograms of posterior samples

# plot all saved MCMC iterations to check convergence