Please help me generate ideas to answer the following questions. you do NOT have
ID: 3663465 • Letter: P
Question
Please help me generate ideas to answer the following questions. you do NOT have to generate any MATLAB codes!
Consider a two-dimensional random walk on a regular lattice:
1. Assuming equal probability of going up, down, left or right, write a MATLAB code generating such walks. Carefully explain how the "decisions" are made (direction of the next step). Use the MATLAB function RAND. 2. The mathematician Pólya showed in 1921 that the probability of returning to the initial position is 1 (the problem is often described as that of a drunkard leaving the pub, walking "randomly" through town and eventually getting back to the pub with probability one, assuming no mugging). Justify/investigate this assertion in any way you want. You have to convince the reader that the statement is correct; copying proofs from the literature is not an option. . Do the same in the three-dimensional case (where it can be proven that the probability of return is strictly less than 1 (0.34)).Explanation / Answer
For random walk
function irr2s (Anzahl, Achse)
% IRR2S(ANZAHL,ACHSE) simulates a two-dimensional symmetric random walk
% (equal probability of going up, down, left or right) and plots it.
% Anzahl is the number of steps.
% The probability distribution (the number of times the same
% point is visited) is plotted over the interval [-achse, achse].
%
% IRR2S uses anzahl = 2000, achse = 50.
% default setting
if (nargin < 2)
Anzahl = 2000;
Achse = 50;
end
clf;
axis square; axis equal;
hold on;
% initialise the starting point and the counter
Position = zeros(2, Anzahl+1);
Zaehler = zeros(2*Achse+1, 2*Achse+1);
Position(1, 1) = 0; Position(2, 1) = 0;
Zaehler(Achse+1, Achse+1) = Zaehler(Achse+1, Achse+1)+1;
% measure the elapsed time
tic;
for x = 1:Anzahl
% choose a direction (N, S, E, W) randomly
Zufall = round(4*rand(1));
if (Zufall == 1)
Position(1, x+1) = Position(1, x)+1;
Position(2, x+1) = Position(2, x);
end;
if (Zufall == 2)
Position(1, x+1) = Position(1, x);
Position(2, x+1) = Position(2, x)+1;
end;
if (Zufall == 3)
Position(1, x+1) = Position(1, x)-1;
Position(2, x+1) = Position(2, x);
end;
if (Zufall == 0)|(Zufall == 4)
Position(1, x+1) = Position(1, x);
Position(2, x+1) = Position(2, x)-1;
end;
if (abs(Position(1, x+1))<Achse)&(abs(Position(2, x+1))<Achse)
Zaehler(Achse+1+Position(1, x+1), Achse+1+Position(2, x+1)) ...
= Zaehler(Achse+1+Position(1, x+1), Achse+1+Position(2, x+1))+1;
end;
end;
toc;
x = 1:Anzahl+1; y = 1:Anzahl+1;
figure(1);
% plot the curve of the random walk
plot(Position(1,x), Position(2,y), 'b-');
figure(2);
% image of the frequency of visiting
imagesc(Zaehler(:, :));
axis off;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.