Skip to content

Instantly share code, notes, and snippets.

@harrysarson
Created October 16, 2017 13:34
Show Gist options
  • Save harrysarson/0c1344dab1ff0ef79b98aa4a9abe02e8 to your computer and use it in GitHub Desktop.
Save harrysarson/0c1344dab1ff0ef79b98aa4a9abe02e8 to your computer and use it in GitHub Desktop.
3F3 Lab
% Plot normal distribution:
figure(1)
x=randn(1000,1);
subplot(211),
hist(x,20)
subplot(212),
ksdensity(x,’width’,0.1)
% Plot uniform distribution:
figure(2)
x=rand(1000,1);
subplot(211),
% Be aware that when specifying bin centres as below, Matlab will include everything
% from -infinity to the first bin centre in the first bin,
% and the top bin to +infnity in the last bin
hist(x,[-1.45:0.1:1.45])
subplot(212),
ksdensity(x,’width’,0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment