0001
0002
0003 R=[0.92 0 0 0 0 0 0 0 0 0 0 0 0.04 0.04];
0004 N=50;
0005 T=100;
0006
0007 t=0:T;
0008 w=zeros(1,T+1);
0009
0010 sum(R.*[-1:(length(R)-2)])
0011
0012 for i=1:6,
0013
0014 subplot(6,1,i);
0015
0016 w(1)=N;
0017 for i=1:T,
0018 if w(i)>0,
0019 w(i+1) = w(i) + rando(R) - 2;
0020 else
0021 w(i+1)=0;
0022 end
0023 end
0024 plot(t,w,'o');
0025 axis([0 T 0 N*1.8]);
0026 end
0027
0028 subplot(6,1,1);
0029 title('Wealth over time playing the slot machine');
0030
0031 subplot(6,1,6);
0032 xlabel('Time');