Optimized 1D GMM