%This is a simple example of a random walk diffusion process
N = 1000; % number of sample paths
K = 1000; %number of steps
u = zeros(1,N);
v = zeros(1,K);

p = 0.4; % probability of left or right step

for j = 1:K
    rstep = rand(1,N);
    ustep = (rstep<p) - (rstep>1-p);
    u = u+ ustep;
    v(j) = u(1);
end

hist(u)
figure(2)
plot(v)
