hw9_solution

hw9_solution - 4/17/09 10:26 PM C:\Documents and...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 4/17/09 10:26 PM C:\Documents and Settings\Kevin Haas\My Documents\cla...\hw8_2.m 1 of 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % problem 8.2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear clc %Input the speed x x=[40 9 100 50 15 65 25 60 95 60 30 125]; %Input the stopping distance y y=[15 2 40 15 4 25 5 25 30 24 8 45]; N=length(x); %Sort the values from lowest to highest [x ind]=sort(x); y=y(ind); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Part (a) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% figure(1) clf plot(x,y, 'x' , 'markersize' ,12, 'linewidth' ,2) xlabel( 'Speed (kph)' ) ylabel( 'Stopping distance (m)' ) grid on %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Part (b) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Find the means and standard deviations xbar=mean(x); s_x=std(x); ybar=mean(y); s_y=std(y); %Find the regression coefficients xy=x.*y; x2=x.*x; beta=(sum(xy)-N*xbar*ybar)/(sum(x2)-N*xbar^2) alpha=ybar-beta*xbar %Regression values yprime yp=alpha+beta*x; %Plot the regression line figure(1) hold on plot(x,yp, 'r' , 'linewidth' ,2) %Find the conditional variance s2yx=1/(N-2)*sum((y-yp).^2); syx=sqrt(s2yx) %Find the correlation coefficient rho=beta*s_x/s_y %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Part (c) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Find the critical value for 10% with 10 dof t_crit=1.8125; %Find the confidence interval 4/17/09 10:26 PM C:\Documents and Settings\Kevin Haas\My Documents\cla...\hw8_2.m 2 of 2 conf=t_crit*syx*sqrt(1/N+(x-xbar).^2/sum((x-xbar).^2)); %Plot the conf interval figure(1) hold on plot(x,yp+conf, 'k' ,x,yp-conf, 'k' , 'linewidth' ,1.5) legend( 'data' , 'yprime' , 'confidence' , 'location' , 'NW' ) 20 40 60 80 100 120 140-10 10 20 30 40 50 Speed (kph) Stopping distance (m) data yprime confidence 4/17/09 10:25 PM MATLAB Command Window 1 of 1 beta = 0.3863 alpha =-1.8611 syx = 2.8049 rho = 0.9819 >> 4/17/09 10:40 PM C:\Documents and Settings\Kevin Haas\My Documents\cla...\hw8_4.mC:\Documents and Settings\Kevin Haas\My Documents\cla....
View Full Document

Page1 / 15

hw9_solution - 4/17/09 10:26 PM C:\Documents and...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online