Load the old-faithful geyser data.

data=read.table("faithful.dat", header=TRUE)
plot(data[,1], data[,2], xlab="Interval", ylab="Duration")

Load the mclust package

library(mclust)
## Package 'mclust' version 5.2.3
## Type 'citation("mclust")' for citing this R package in publications.
?em
?mclustModelNames

Different Gaussian mixture models:

Try K=2 with model “VVI”

K=2; n=length(data[,1])
z=matrix(0,n, K); 
id=sample(1:K, n, replace=TRUE);
for(i in 1:n) z[i,id[i]]=1;

tmp=mstep(modelName="VVI", data, z)
myout=em(modelName="VVI", data, parameters=tmp$parameters);

surfacePlot(data, parameters=myout$parameters, nlevels=10)
points(data, col="blue")