Compute and plot the path(s) of a set of random walkers which are confined by
a pair of barriers at +B units and -B units from the origin (where the walkers
all start from).
A random walk is computed by repeatedly performing the calculation
xj+1 = xj + s
where s is a number drawn from the standard normal distribution (randn in
MATLAB).For example, a walk of N steps would be handled by the code fragment
x(1) = 0;
for j = 1:N
x(j+1) = x(j) + randn(1,1);
end
There are three possible ways that the walls can act:
a. Reflecting In this case, when the new position is outside the walls, the
walker is bounced back by the amount that it exceeded the barrier.
That is,
when xj+1 > B,
xj+1 = B |B xj+1|
when xj+1 < (-B),xj+1 = (-B) + |(-B) – xj+1|If you plot the paths, you should not see any positions that are beyond |B|units from the origin.b. Absorbing – In this case, if a walker hits or exceeds the wall positions, it”dies” or is absorbed and the walk ends.For this case, it is of interestto determine the mean lifetime of a walker (i.e., the mean and distributionof the number of steps the “average” walker will take before being absorbed). c. Partially absorbing – This case is a combination of the previous two cases.When a walker encounters a wall, “a coin is flipped” to see if the walkerreflects or is absorbed.Assuming a probability p (0 < p < 1) for reflection, the pseudo-code fragment that follows uses the MATLAB uniform random-number generator to make the reflect/absorb decision: if rand < preflectelseabsorbendWhat do you do with all the walks that you generate?Compute statistics, of course.You should answer questions like What is the average position of the walkers as a function of time?What is the standard deviation of the position of the walkers as a functionof time?Does the absorbing or reflecting character influence these summaries?For the absorbing/partial-reflection case, a plot of the number of survivingwalkers as a function of step numbers is a very interesting thing. Useful, informative and interesting, particularly if graphically displayed.Report RequirementIn your project report, you need toDescribe the process of getting the answers and explain your graph or table. You have to make it understandable to students with basic knowledge of the pre-requisites and the course materials covered so far. In general, you should type it up in a word document and copy and paste any relevant results from MATLAB.Append your MATLAB programs at the end of your document or submit them as separate files.Organize your report according to the questions asked.Submitting onlyMATLAB files will result in very few points.
Reviews
There are no reviews yet.