g = g + (1./(n.*sqrt(2*pi).*sigma(k)).*exp(-1.*((x-x0(k)).^2/(2.*sigma(k).^2))));