% The script file pwsema04 gives examples of simple random
% sequences: 1) White Gaussian Sequence, 2) Brownian Motion Sequence,
% 3) not differentiable stationary process.

% White Gaussian Sequence
sigma=1; r=50; 
WGS=randn(r,1);
plot(WGS,'k*')
title('White Gaussian Sequence')
pause
close

% Brownian Motion Sequence
sigma=2; dt=0.01; beta=sigma*sqrt(dt); n=300;
s=100; bmp=zeros(1,s); BM=bmp;
for r=1:n
   bma=bmp+beta*beta*randn(1,s);
   BM=[BM;bma];
   bmp=bma;
end   
T=0:dt:n*dt;
plot(T,BM)
title('Brownian Motion Sequence')
pause
close

% Not differentiable stationary sequence with no dominant frequency
sigma=1; dt=0.01; n=300; eta=1/5; sigma=1; 
gamma=exp(-eta*dt); beta=sqrt(1-gamma*gamma);s=10;
ap=sigma*randn(1,s); A=[ap];
for r=1:n
   aa=gamma*ap+beta*sigma*randn(1,s);
   A=[A;aa];
   ap=aa;
end   
T=0:dt:n*dt;
plot(T,A)
title('Not differentiable stationary seq. with no dominant frequency')

pause
close
