%stat351 stat351-histogram.m %Histograms and empirical distributions >>X=exprnd(1,10000,1); %[N,X] = HIST(...) also returns the position of the bin centers in C. >>[N,C]= hist(X,10) >>N' ans = 5946 2351 1007 420 173 60 23 14 4 2 >>C' ans = 0.4619 1.3857 2.3094 3.2332 4.1569 5.0807 6.0045 6.9282 7.8520 8.7757 %sample freqency >>f= N'/10000 f = 0.6054 0.2419 0.0930 0.0339 0.0154 0.0062 0.0018 0.0017 0.0002 0.0005 >>sum(f) ans = 1.0000 %E(X) C'.*f >>sum(C'.*f) ans = 1.0633 %Simulation X=unifrnd(0,1,10,10000); >> size(X) ans = 10 10000 >> help max MAX Largest component. For vectors, MAX(X) is the largest element in X. For matrices, MAX(X) is a row vector containing the maximum element from each column. >>X_n =max(X); >> size(X_n) ans = 1 10000 [N,C]=hist(X_n,10); f=N'/10000; >> plot(C',f,'-')