% plot 2-D random walk in different ways
function plot_brown2(varargin)
    if nargin == 0
       n=10000;
       step_type=1;
    elseif nargin==1
       n=varargin{1};
       step_type=1;
    elseif nargin==2
       n=varargin{1};
       step_type=varargin{2};
    else
       return;
    end


%n=100;
clear x;
clear y;
switch step_type
    case 1
       x=2*round(rand(1,n))-1;
       y=2*round(rand(1,n))-1;
    case 2
       p=randi(4,[1,n]);
       x=real(i.^p);
       y=imag(i.^p);
    case 3
       theta=2 * pi*randi(6,[1,n])/6;
       x=cos(theta);
       y=sin(theta);
    case 4
       theta=2*pi*rand(1,n);
       x=cos(theta);
       y=sin(theta);
    case 5
       x=randn(1,n);
       y=randn(1,n);
end % switch

figure 
hold on
grid on
title('2-dimensional random walk');
axis equal
plot(cumsum(x),cumsum(y));
%figure 
%hold on
%title('Plot of absolute value of random walk')
%plot(abs(cumsum(x)+i*cumsum(y)))
return

