function [] = ScaledRandomWalk(tend,n,check)

tic
rand('state',20000)
R1 = rand([n,1]);
source = 1;

T = zeros([n,1]);

B = zeros([n,1]);


h = tend/n;


for i = 1:n-1
   
    r = R1(source);
    source = source + 1;
    
    if r > 1/2
        val = 1;
    else
        val = -1;
    end
    
    B(i+1) = B(i) + sqrt(h)*val;
    
    T(i+1) = T(i) + h;
     
end


if check == 1
    figure
    plot(T(1:i+1),B(1:i+1))
    legend('Interpolated Random Walk')
end
    
% figure
% plot(T,B)
% legend('B_n')

toc