Graded Assignment
Assignment (due 3 November)
Complete the tasks described below and write a short (at most four pages, including graphs) report explaining what you've done and what it demonstrates.
Throughout this lab assignment you will be simulating the heights of men randomly drawn from a large population of college-age men whose heights are normally distributed with mean 70 inches and standard deviation 2.5 inches.
% This function takes as arguments a vector of left endpoints, % a vector of right endpoints, and a number, and plots parallel % line segments for the left/right endpoint pairs, with a horizontal % line segment at the third argument. The function returns the % proportion of the intervals that contain the third argument. function p = plotconfints(L,R,parameter) figure hold on n = length(L); for i = 1:n if L(i)<=parameter & R(i)>=parameter plot([i i],[L(i) R(i)],'g-') else plot([i i],[L(i) R(i)],'xr-') end end bottom = min(L) - 0.1*(max(R)-min(L)); top = max(R) + 0.1*(max(R)-min(L)); left = floor(-0.1*n); right = ceil(1.1*n); axis([left right bottom top]) plot([left right],[parameter parameter],'bd-') hold off numbercontainingparameter = sum(L<=parameter & R>=parameter); p = numbercontainingparameter/length(L);
heights = normrnd(70, 2.5, 100, 5);Recall that row (i.e., sample) means can be found with the mean command, where a second argument of dimension=2 indicates to take row means instead of the default column means:
samplemeans = mean(heights,2);Finding the row (i.e.,sample) standard deviations can be done with the std command, similar to the mean command, only three arguments are required. The first is the matrix of data, the third is the dimension (2 for rows), and the middle argument is a "flag" of either 0 or 1, indicating whether the standard deviation should be computed using n or n-1 as the divisor. You should use n-1, so the flag should be 0:
stdheights = std(heights,0,2);