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/code/gaussianbins.m

19 lines
425 B
Matlab

x = randn( 100, 1 ); % generate some data
bins1 = -4:2:4; % large bins
bins2 = -4:0.5:4; % small bins
subplot( 1, 2, 1 );
hold on;
hist( x, bins1 );
hist( x, bins2 );
xlabel('x')
ylabel('Frequeny')
hold off;
subplot( 1, 2, 2 );
hold on;
% normalize to the rigtht bin size:
hist( x, bins1, 1.0/(bins1(2)-bins1(1)) );
hist( x, bins2, 1.0/(bins2(2)-bins2(1)) );
xlabel('x')
ylabel('Probability density')
hold off;