hw8_solution

hw8_solution - 4/7/09 10:58 AM C:\Documents and...

Info iconThis preview shows pages 1–9. 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

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/7/09 10:58 AM C:\Documents and Settings\Kevin Haas\My Documents\c...\rayleigh.m 1 of 3 clear clc %Data x=[48.4 47.1 49.5 116 84.1 99.3 108.1 47.3 93.7 36.3 122.5 52.7 44.5 84.8 52.6 53.6 33.5 43.8 56.3 34.5 62.8 180.5 42.4 146.2 115.2 43 103.6 64.7 69.8 44 36.2 50.6 %Number of samples %Specify bin locations % x<45 % 45<X<70 % 70<X<95 % 95<X<120 % x>120 %Plot frequency histogram figure(2) clf 4/7/09 10:58 AM C:\Documents and Settings\Kevin Haas\My Documents\c...\rayleigh.m 2 of 3 subplot(311) bar(w,ni, 'histc' ) grid on xlabel( 'Strain (micro-in/in)' ) ylabel( 'Number of Observations' ) set(gca, 'xlim' ,[0 max(x)]) %Compute the fraction and plot subplot(312) bar(w,fi, 'histc' ) grid on xlabel( 'Strain (micro-in/in)' ) ylabel( 'Fraction of Observations' ) set(gca, 'xlim' ,[0 max(x)]) %Plot the density for i=1:numbin end subplot(313) bar(w,den, 'histc' ) grid on xlabel( 'Strain (micro-in/in)' ) ylabel( 'Probability Density' ) set(gca, 'xlim' ,[0 max(x)]) %Find moments and parameters %Plot the theoretical pdf subplot(313) hold on plot(x,f, 'r.' ) %Find the theoretical frequency for each bin %Put upper limit to infinity %Find the CDF at each bin border %Find the prob of each bin by difference of CDF %theoretical frequency %Perform Chi-squared test % Critical value from table A.4 A=0.01 f=3 disp( 'Perform Chi-squared test' ) disp([ 'Error = ' ,num2str(err), ' C_crit = ' 4/7/09 10:58 AM C:\Documents and Settings\Kevin Haas\My Documents\c...\rayleigh.m 3 of 3 if err<c_crit disp( 'Passes Chi-squared test' ) else disp( 'Fails Chi-squared test' ) end 4/7/09 10:59 AM MATLAB Command Window 1 of 1 Perform Chi-squared test Error = 4.1683 C_crit = 11.3449 Passes Chi-squared test >> Bins ni ei (ni-ei)^2/ei 0<x<45 9.000 8.362 0.049 45<x<70 12.000 8.366 1.578 70<x<95 3.000 7.299 2.532 95<x<120 5.000 4.842 0.005 x>120 4.000 4.131 0.004 Total 4.168 20 40 60 80 100 120 140 160 180 2 4 6 8 10 12 Strain (micro-in/in) Number of Observations 20 40 60 80 100 120 140 160 180 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 Strain (micro-in/in) Fraction of Observations 20 40 60 80 100 120 140 160 180 0.005 0.01 0.015 Strain (micro-in/in) Probability Density 4/7/09 11:02 AM C:\Documents and Settings\Kevin Haas\My Documents\...\conc_plot.m 1 of 4 clear clc %Load the data load conc.dat % Number of samples % Bin width % Find the histogram %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Part (a) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Plot histogram figure(2) clf subplot(311) bar(xi,ni,1) grid on xlabel( 'Concentration (ppm)' ) ylabel( 'Number of Observations' ) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Part (b) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Compute the fraction and plot subplot(312) bar(xi,fi,1) grid on xlabel( 'Concentration (ppm)' ) ylabel( 'Fraction of Observations' ) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Part (c) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Plot the probability density...
View Full Document

Page1 / 25

hw8_solution - 4/7/09 10:58 AM C:\Documents and...

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

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