% Matlab demonstration of how a density curve can be used to estimate % a distribution of data. % draw 10000 height samples from male population mu=68.5;sigma=5.5;n=10000; test_value=64; X=normrnd(mu,sigma,n,1); % vector for density curve x=[45:0.01:95]; y=normpdf(x,mu,sigma); figure(1);clf; subplot(2,1,1); title('Using a density curve to approximate a data distribution, N(68.5,5.5).'); xlabel('Heights of 10000 men in inches.'); ylabel('Proportion of men at each height.'); % plot histogram of sample binwidth=2; bins=[41:binwidth:89]; N=hist(X,bins);hold on; N=N/(n*binwidth); bar(bins,N,1); % plot density curve plot(x,y,'r'); axis([45 95 0 0.08]); % find area to the left of test_value less_hist=find(X