Porting Goodbourn's mixture model MATLAB code to R.