For my second lecture today, I need to plot a likelihood surface for a basic two-component mixture with only the means unknown: here is the R code to speed up things llsurf=function(trumyn=2.,wayt=.3,var2=1.,ssiz=500){ # draws the log-likelihood surface and a random sample sd2=sqrt(var2) parti=(runif(ssiz)>wayt) sampl=(1-parti)*rnorm(ssiz)+parti*(trumyn+sd2*rnorm(ssiz)) mu2=mu1=seq(min(sampl),max(sampl),.1) mo1=mu1%*%t(rep(1,length(mu2))) mo2=(rep(1,length(mu2)))%*%t(mu2) ca1=-0.5*mo1*mo1 ca2=-0.5*mo2*mo2 like=.1*(ca1+ca2) # log prior N(0,10) for