This repository has been archived on 2021-05-17. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
scientificComputing/statistics/code/diehistograms.m
2015-10-20 18:26:43 +02:00

25 lines
494 B
Matlab

% dependence of histogram on number of rolls:
nrolls = [ 20, 100, 1000 ];
for i = [1:length(nrolls)]
d = rollthedie( nrolls(i) );
% plain hist:
%hist( d )
% check bin counts of plain hist:
% h = hist( d )
% force 6 bins:
%hist( d, 6 )
% set the right bin centers:
%bins = 1:6;
%hist( d, bins )
% normalize histogram and compare to expectation:
hold on
plot( [0 7], [1/6 1/6], '-r', 'linewidth', 10 )
hist( d, bins, 1.0, 'facecolor', 'b' )
hold off
pause
end