Page 175 % make up an m-file, gaussian.m containing % function y=gaussian(x,m,s); % m=mean, s=stddev % % note 1/sqrt(2*pi) = .3989422803 % y=(.3989422803/s)*exp(-0.5*((x-m)./s).^2); x=[-10:.1:10]; y=gaussian(x,0,1); plot(x,y); hold on; y=gaussian(x,0,2); plot(x,y); y=gaussian(x,0,4); plot(x,y); Exercises/Experiments 1. particles=500; steps=40; for k=1:particles steplog=fix(2*rand(1,steps)); % ran. vec. of 0's/1's steplog = 2*steplog-1; % ran. vec. of -1/+1 place(k) = sum(steplog); % endpt for this 40 step walk end x=-20:2:20; hist(place,x) 1a. % Eqn (6.2.9) is the gaussian with mean=0 and % stddev = sqrt(2Dt). Therefore make an m-file % gaussian.m, (already done in Section 2.6, repeated here) % function y=gaussian(x,m,s); % y=(.3989422803/s)*exp(-0.5*((x-m)./s).^2); % Part (a) D=1; t=1; s=sqrt(2*D*t); x=[-10:.1:10]; y=gaussian(x,0,s); plot(x,y); hold on; D=1; t=2; s=sqrt(2*D*t); y=gaussian(x,0,s); plot(x,y); D=1; t=3; s=sqrt(2*D*t); y=gaussian(x,0,s); plot(x,y);