function x = randomwalk(n,p) r = rand(n,1); r(r=p) = +1.0; x = cumsum(r); end