This repository has been archived on 2021-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
scientificComputing/programming/exercises/randomwalkscriptd.m

23 lines
537 B
Matlab

thresh = 50.0;
probs = 0.5:0.01:1.0;
reps = 1000;
meancount = zeros(length(probs), 1);
stdcount = zeros(length(probs), 1);
for sp = 1:length(probs)
p = probs(sp);
positions = zeros(reps, 1);
for k = 1:reps
x = randomwalkthresh(p, thresh);
positions(k) = length(x);
end
meancount(sp) = mean(positions);
stdcount(sp) = std(positions);
end
semilogy(probs, meancount, 'displayname', 'mean');
hold on;
semilogy(probs, stdcount, 'displayname', 'std');
hold off;
xlabel('p');
xlim([0.5 1.0])
ylabel('number of steps');
legend('show');