% Digital simulation of the walk in a plane (or in three-dimensional space)
% of a (pseudo) fractional brownian motion by using the
% function fBr = makebrownian(n,H,par) with:
%
%  Inputs
%    n       signal length
%    H       base of digits in expansion
%    par     optional, degree of extension in algorithm, default =8.
%  Outputs
%    fBr     (pseudo) Fractional Brownian signal
%
%  Description
%    Uses a Frequency Domain algorithm to get a pseudo Brownian Motion
%    The law is NOT normalized to give unit variance to unit increments

t=10000;
H=0.5; 
fBr1 = makebrownian(t,H);
fBr2 = makebrownian(t,H);
%fBr3 = makebrownian(t,H);

for tn=1:1:t;
a1=fBr1(1:tn);
b2=fBr2(1:tn);
%c3=fBr3(1:tn);
Mi1=min(fBr1);
Mi2=min(fBr2);
%Mi3=min(fBr3);
Mx1=max(fBr1);
Mx2=max(fBr2);
%Mx3=max(fBr3);
pause(0.00000001)

l1=plot(a1,b2,'b');
%l1=plot3(a1,b2,c3,'b');
title('Brownian Motion for a Hurst exponent h=0.5');
axis([Mi1 Mx1 Mi2 Mx2]); axis('off');
%axis([Mi1 Mx1 Mi2 Mx2 Mi3 Mx3]);box;

end


% "Complex and Chaotic Nonlinear Dynamics. 
% Advances in Economics and Finance, 
% Mathematics and Statistics" 
% T.Vialar, Springer 2009.
% Copyright(c).
