This repository has been archived on 2021-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
scientificComputing/statistics/exercises/diehist.m

15 lines
359 B
Matlab

function diehist( x )
% plots a normalized histogram of random numbers x drawn from rolling a
% die.
[h,b] = hist( x, 1:6 );
h = h/sum(h); % normalization
plot( [0 7], [1/6 1/6], 'r', 'linewidth', 3 )
hold on
bar( b, h );
hold off
set(gca, 'XTick', 1:6 );
xlim( [ 0, 7 ] );
xlabel('Eyes');
ylabel('Probability');
end