clear all %%%%%%%%%%%%%%%%%%%%%%% % Pie Chart: % Ingrediants for a Sausage Mushroom Pizza weighing 1.6kg % Sausage: 0.12kg % Cheese: 0.4Kg % Crust: 0.8Kg % Tomato Sauce: 0.2Kg % Mushrooms: 0.08Kg % ------------------- % Pizza: 1.6Kg pizza=[0.12 0.4 0.8 0.2 0.08]; figure; pie(pizza,{'Sausage','Cheese','Crust','Tomato Sauce','Mushrooms'}); %%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%% %%% For the histogram: %%% Ask everyone in the room to tell me something about themselves realtime. %%% Such as their heights (cm), age (year.month) etc. nbins=70; z=rand(300,1); edg=min(z)+[0:1:nbins]*((max(z)-min(z))/nbins); freq_z=histc(z,edg); figure; bar(edg,freq_z,'k') %%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%% %%% For the CLT, use a simulation study: n=30;%number of observations n_sims=1e4;%number of simulations x=randn(n,n_sims);%matrix with pseudo-random values drawn from a normal distribution %with mean zero and standard deviation onepseudo-random values x_bar=mean(x);%vector of the mean values of every column in the matrix x nbins=1e2; v=x_bar; edg=min(v)+[0:1:nbins]*((max(v)-min(v))/nbins); freq_v=histc(v,edg); %%%% %% frequency histogram %%%% figure; subplot(211) bar(edg,freq_v,'b') xlabel('Sample mean') ylabel('Frequency') %%%% %% probability histogram %%%% % figure; prob_v=freq_v/sum(freq_v); subplot(212) bar(edg,prob_v,'r') xlabel('Sample mean') ylabel('Probability')