a): We run a shorter simulation (\(10^4\) dice rolls)…
Random walk
Mean height
Mean squared height
Random walk
Mean height
Mean squared height
clc; clf; clear all; close all maxIter = 10000000; walkY = zeros(maxIter,1); walkX = zeros(maxIter,1); hMean = zeros(maxIter,1); h2Mean = zeros(maxIter,1); for i = 2:maxIter if rand >= 0.5 walkY(i) = walkY(i-1) + 1; else walkY(i) = walkY(i-1) - 1; end walkX(i) = walkX(i-1) + 1; hMean(i) = mean(walkY(1:i)); h2Mean(i) = mean(walkY(1:i).^2); end figure(1) plot(walkX(1:3122344), walkY(1:3122344)) xlabel('Time $t$', 'FontSize', 15, 'interpreter', 'latex') ylabel('$h$', 'FontSize', 15, 'interpreter', 'latex') set(gcf, 'PaperPositionMode', 'auto'); print('walkLong.png', '-dpng', '-r300') figure(2) plot(walkX(1:3122344), hMean(1:3122344)) xlabel('Time $t$', 'FontSize', 15, 'interpreter', 'latex') ylabel('Mean of $h$', 'FontSize', 15, 'interpreter', 'latex') set(gcf, 'PaperPositionMode', 'auto'); print('meanHLong.png', '-dpng', '-r300') figure(3) plot(walkX(1:3122344), h2Mean(1:3122344)) xlabel('Time $t$', 'FontSize', 15, 'interpreter', 'latex') ylabel('Mean of $h^2$', 'FontSize', 15, 'interpreter', 'latex') set(gcf, 'PaperPositionMode', 'auto'); print('meanH2Long.png', '-dpng', '-r300')
b): The average of \(h\) will go to zero, for very large times - each step is just as likely to increase the height by one, as it is to decrease it!
c): The average of \(h^2\) up to time t will be proportional to t for very large times. Don't worry if your data showed different trends - it can sometimes take very large times to see this!
d): Since the average of the height goes to zero for long walks, it is not very useful. The average of the square of the height is more useful since there are no cancellations - taking the square root of this quantity gives a good measure of how much the particle has moved.
e): See the animation following the exercise for a large-scale example of this!