Univariate MATLAB code, initial commit; courtesy of Dharsh.