Untitled

 avatar
unknown
matlab
2 years ago
303 B
5
Indexable
numSteps = 100;     
numWalks = 10000;    

endPositions = zeros(1, numWalks);

for i = 1:numWalks
    steps = randsrc(1, numSteps, [-1, 1]);   
    endPositions(i) = sum(steps);           
end

histogram(endPositions, 'Normalization', 'probability');
xlabel('Position');
ylabel('Sannolikhet');
grid on;
Editor is loading...