CodeCodeCode

ENGR132: HW07 - hw07_sampling_name

May 6th, 2012
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.93 KB | None | 0 0
  1. %  Program Description: Generate 10, 100, and 1000 Gaussian random number
  2. %  sets with a mean of 80 and standard deviation of 25 and makes a histogram out of the data.
  3.  
  4. % --- INPUTS ---
  5. %Generates 10, 100, and 1000 random number sets with mean 80 and stdev 25 in a 1000 by 1
  6. %matrix.
  7. data_set1 = normrnd(80,25,10,1);
  8. data_set2 = normrnd(80,25,100,1);
  9. data_set3 = normrnd(80,25,1000,1);
  10.  
  11. % --- CALCULATIONS ---
  12. %Finds the mean and standard deviation of the data.
  13. fprintf('\nThe mean of Dataset 1 is %0.3f with a standard deviation of %0.3f.\n', mean(data_set1), std(data_set1));
  14. fprintf('The mean of Dataset 2 is %0.3f with a standard deviation of %0.3f.\n', mean(data_set2), std(data_set2));
  15. fprintf('The mean of Dataset 3 is %0.3f with a standard deviation of %0.3f.\n', mean(data_set3), std(data_set3));
  16.  
  17. % --- OUTPUTS ----
  18. %Creates a histogram based on the given data.
  19. subplot(3,1,1), hist(data_set1);
  20. title('Distribution of random 10 numbers');
  21. xlabel('Value of number');
  22. ylabel('Frequency');
  23. grid;
  24. subplot(3,1,2), hist(data_set2);
  25. title('Distribution of random 100 numbers');
  26. xlabel('Value of number');
  27. ylabel('Frequency');
  28. grid;
  29. subplot(3,1,3), hist(data_set3);
  30. title('Distribution of random 1,000 numbers');
  31. xlabel('Value of number');
  32. ylabel('Frequency');
  33. grid;
  34.  
  35. % The mean of Dataset 1 is 81.888 with a standard deviation of 21.287.
  36. % The mean of Dataset 2 is 80.745 with a standard deviation of 24.621.
  37. % The mean of Dataset 3 is 80.652 with a standard deviation of 25.548.
  38.  
  39. %a) The less data there is, the harder it was to tell which bin had the
  40. %largest frequency.  As such, one can find that more data presents a better
  41. %idea of what is going on with said data.
  42. %b) The more data there is, the ore the data began to represent a bell
  43. %curve.
  44. %c) As stated before, getting more data allows one to better see what is
  45. %going on with said data and get a better idea what is going on with the
  46. %source of whatever data it is.
Advertisement
Add Comment
Please, Sign In to add comment