%time change

T=5;
dt=0.0001;
t=[0:dt:T];
n=size(t);
n=n(2);

clf reset;
 
Bmt = cumsum(sqrt(dt)*randn(1,n));
plot(t,Bmt(1:n),'Color',[0 0 0]);
hold on;
   
inand=Bmt(1:n-1); %intergrand
   
%   inand=inand.^2;
%   inand=abs(inand); 
%   inand=sqrt(abs(inand)); 
%   inand=([1:n-1]*dt).^(-1/4);
%   inand=(abs(inand)).^(-1/4);
%   inand=exp(-[1:n-1]*dt+abs(Bmt(1:n-1)));    
   

    
intor=Bmt(2:n)-Bmt(1:n-1); %integrator
pr=inand.*intor;
It=cumsum(pr); %integral
QV=cumsum(inand.^2)*dt; %quadratic variation

plot(t(1:n-1), It, 'Color',[1 0 0]);

plot(t(1:n-1),QV,'Color',[0 0.5 0]);

plot(QV, It, 'Color',[0 0 1]);


legend('B.m.', 'St. int', 'QV', 'time ch.','Location', 'northeastoutside');
hold on;
   
title('Time change from Ito integral to Brownian motion');

