function [fieldin,field] = randfield(sig,siz)
%% Produce a zero mean Random field with a correlation length sigma.
fieldin = randn(siz);

if (floor(siz/2)*2 == siz) % is even
    x= -(siz/2)+1:(siz/2);
else
    x = -floor(siz/2):floor(siz/2);
end

y = exp(-(x.*x).*sig^2);
g = (y'*y)*siz*siz*sig;

field = real(ifft2(fftshift(fieldin.*g)));
end
