% % Written by: % -- % John L. Weatherwax 2006-12-31 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- clc; close all; randn('seed',0); rand('seed',0); N = 10000; % index: 1 , 2 , 3 , 4 , 5 n_i = zeros(1,5); % holds n_{15},n_{16},n_{17},n_{18},n_{19} for ii=1:N, x = 0; while( 1 ) roll = randi(6); if( roll==6 ) x = 0; else x = x + roll; end if x>=15 break; end end spot = x - 15 + 1; n_i(spot) = n_i(spot) + 1; end disp('probabilities of each n_i are'); n_i / N disp('expectation of winning are'); dot( 15:19, n_i/N )