function x = rednoise(r,N)
%function x = rednoise(r,N)
%  Outputs row N-vector x of standardized Gaussian red noise with 
%  autocorrelation r

  w = randn(N);  % White noise vector
  x = zeros(1,N);
  s = sqrt(1 - r^2);
  x(1) = w(1);
  for j = 1:(N-1)
    x(j+1) = r*x(j) + s*w(j+1);
  end  
end

