14 lines
330 B
Matlab
14 lines
330 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', 6 )
|
|
hold on
|
|
bar( b, h );
|
|
hold off
|
|
xlim( [ 0, 7 ] );
|
|
xlabel('Eyes');
|
|
ylabel('Probability');
|
|
end
|