diff options
Diffstat (limited to '1202/CH21')
-rwxr-xr-x | 1202/CH21/EX21.2/21_2.png | bin | 0 -> 13259 bytes | |||
-rwxr-xr-x | 1202/CH21/EX21.2/21_2.sce | 96 | ||||
-rwxr-xr-x | 1202/CH21/EX21.3/21_3.png | bin | 0 -> 15453 bytes | |||
-rwxr-xr-x | 1202/CH21/EX21.3/21_3.sce | 67 | ||||
-rwxr-xr-x | 1202/CH21/EX21.4/21_4.sce | 22 | ||||
-rwxr-xr-x | 1202/CH21/EX21.5/21_5.sce | 72 | ||||
-rwxr-xr-x | 1202/CH21/EX21.5/21_5a.png | bin | 0 -> 11411 bytes | |||
-rwxr-xr-x | 1202/CH21/EX21.5/21_5b.png | bin | 0 -> 7261 bytes | |||
-rwxr-xr-x | 1202/CH21/EX21.6/21_6.png | bin | 0 -> 7791 bytes | |||
-rwxr-xr-x | 1202/CH21/EX21.6/21_6.sce | 60 |
10 files changed, 317 insertions, 0 deletions
diff --git a/1202/CH21/EX21.2/21_2.png b/1202/CH21/EX21.2/21_2.png Binary files differnew file mode 100755 index 000000000..6988389cd --- /dev/null +++ b/1202/CH21/EX21.2/21_2.png diff --git a/1202/CH21/EX21.2/21_2.sce b/1202/CH21/EX21.2/21_2.sce new file mode 100755 index 000000000..c0e5b10f2 --- /dev/null +++ b/1202/CH21/EX21.2/21_2.sce @@ -0,0 +1,96 @@ +clear +clc + +//Example 21.2 +disp('Example 21.2') + +//data +x=[209.6 207.6 211.1 + 183.5 193.1 202.4 + 190.1 206.8 201.6 + 206.9 189.3 204.1 + 260. 209. 212.2 + 193.9 178.8 214.5 + 206.9 202.8 189.7 + 200.2 192.7 202.1 + 210.6 192.3 205.9 + 186.6 201.5 197.4 + 204.8 196.6 225. + 183.7 209.7 208.6 + 185.6 198.9 191.5 + 202.9 210.1 208.1 + 198.6 195.2 150. + 188.7 200.7 207.6 + 197.1 204. 182.9 + 194.2 211.2 215.4 + 191. 206.2 183.9 + 202.5 197.1 211.1 + 185.1 186.3 188.9 + 203.1 193.1 203.9 + 179.7 203.3 209.7 + 205.3 190. 208.2 + 203.4 202.9 200.4 ] + + +//Original Limits +n=3; +xbar=sum(x,2)/n; //mean calculation +s=sqrt(1/(n-1)*sum((x-repmat(xbar,1,3)).^2,2)); //standard deviation calculation +p=length(xbar);//no. of subgroups +xbarbar=sum(xbar,1)/p; +sbar=sum(s,1)/p; + +c4=0.8862;B3=0;B4=2.568;c=3; +sigma=1/c4*sbar/sqrt(n); +//original limits +UCL_x=xbarbar+c*sigma;//Eqn21-9 +LCL_x=xbarbar-c*sigma;//Eqn 21-10 + +UCL_s=B4*sbar;//Eqn21-14 +LCL_s=B3*sbar;//Eqn21-15 + +//Modified Limits +x_mod=x; +x_mod([5 15],:)=[]; +n=3; +xbar_mod=sum(x_mod,2)/n; //mean calculation +s_mod=sqrt(1/(n-1)*sum((x_mod-repmat(xbar_mod,1,3)).^2,2)); //standard deviation calculation +p_mod=length(xbar_mod);//no. of subgroups +xbarbar_mod=sum(xbar_mod,1)/p_mod; +sbar_mod=sum(s_mod,1)/p_mod; + +c4=0.8862;B3=0;B4=2.568;c=3; +sigma_mod=1/c4*sbar_mod/sqrt(n); +//modified limits +UCL_x_mod=xbarbar_mod+c*sigma_mod;//Eqn21-9 +LCL_x_mod=xbarbar_mod-c*sigma_mod;//Eqn 21-10 + +UCL_s_mod=B4*sbar_mod;//Eqn21-14 +LCL_s_mod=B3*sbar_mod;//Eqn21-15 + + + +mprintf('\n Original Limits Modified Limits') +mprintf('\n xbar Chart Control Limits ') +mprintf('\n UCL %f %f',UCL_x,UCL_x_mod) +mprintf('\n LCL %f %f',LCL_x,LCL_x_mod) +mprintf('\n s Chart Control Limits ') +mprintf('\n UCL %f %f',UCL_s,UCL_s_mod) +mprintf('\n LCL %f %f',LCL_s,LCL_s_mod) + +subplot(2,1,1); +plot2d(repmat(UCL_x,1,p)); +plot(repmat(UCL_x_mod,1,p),'--'); +plot2d(repmat(LCL_x,1,p)); +plot(repmat(LCL_x_mod,1,p),'--'); +plot2d(xbar,style=-1,rect=[0,160,30,260]) +xtitle('Example 21.2','Sampling number','$\text{Thickness}\ (\AA)$') +legend('Original Limits','Modified Limits') + +subplot(2,1,2); +plot2d(repmat(UCL_s,1,p)); +plot2d(repmat(LCL_s,1,p)); +plot(repmat(UCL_s_mod,1,p),'--'); +plot(repmat(LCL_s_mod,1,p),'--'); +plot2d(s,style=-1,rect=[0,0,30,30]) +xtitle('','Sampling number','$\text{Standard Deviation}\ (\AA)$') diff --git a/1202/CH21/EX21.3/21_3.png b/1202/CH21/EX21.3/21_3.png Binary files differnew file mode 100755 index 000000000..3d73b52ca --- /dev/null +++ b/1202/CH21/EX21.3/21_3.png diff --git a/1202/CH21/EX21.3/21_3.sce b/1202/CH21/EX21.3/21_3.sce new file mode 100755 index 000000000..aedca9747 --- /dev/null +++ b/1202/CH21/EX21.3/21_3.sce @@ -0,0 +1,67 @@ +clear +clc + +//Example 21.3 +disp('Example 21.3') + + +T=70;sigma=3;p=100;//p is the no. of samples +x=grand(p,1, "nor", T, sigma); +delta=0.5*sigma; +x(11:$)=x(11:$)+delta; + +//Limits for Shewart charts +UCL_1=T+sigma*3; +LCL_1=T-sigma*3; + +subplot(3,1,1); +plot2d(repmat(UCL_1,1,p)); +plot2d(repmat(LCL_1,1,p)); +plot2d(x,style=1,rect=[0,60,100,80]) +xtitle('Example 21.3','Sampling number','Strength (MPa)') + +//CUSUM +Cplus=zeros(100,1);Cminus=zeros(100,1); +K=0.5*sigma;H=5*sigma; +UCL_2=H; + +for k=2:100 + Cplus(k)=max(0,x(k)-(T+K)+Cplus(k-1)); + Cminus(k)=max(0,(T-K)-x(k)+Cminus(k-1)); + if Cplus(k-1)>H then + Cplus(k)=0; + end + if Cminus(k-1)>H then + Cminus(k)=0; + end + +end + + +subplot(3,1,2); +plot2d(Cplus,style=1,rect=[0,0,100,20]); +plot2d(Cminus,style=2,rect=[0,0,100,20]); +plot2d(repmat(UCL_2,1,p)); +xtitle('','Sampling number','CUSUM') +legend('Cplus','Cminus') + +//EWMA +lamda=0.25; +z=x; +for k=2:100 + z(k)=lamda*x(k)+(1-lamda)*z(k-1); +end +UCL_3=T+3*sigma*sqrt(lamda/(2-lamda)); +LCL_3=T-3*sigma*sqrt(lamda/(2-lamda)); + +subplot(3,1,3); +plot2d(repmat(UCL_3,1,p)); +plot2d(repmat(LCL_3,1,p)); +plot2d(z,style=1,rect=[0,65,100,75]) +xtitle('','Sampling number','EWMA') + + +mprintf('The charts in the example and in the book differ due\n... +a different realization of data everytime the code is run\n... +due to the grand command. If we had the exact data as that given\n... +in the book our charts would have matched.') diff --git a/1202/CH21/EX21.4/21_4.sce b/1202/CH21/EX21.4/21_4.sce new file mode 100755 index 000000000..639912321 --- /dev/null +++ b/1202/CH21/EX21.4/21_4.sce @@ -0,0 +1,22 @@ + +clear +clc + +//Example 21.4 +disp('Example 21.4') + +xbar=199.5;//Note that this is the correct value and not 199 +sbar=8.83; +USL=235;//Note that this is diff from UCL +LSL=185; +c4=0.8862; +n=3; +sigma=5.75; +sigma_x=sbar/c4/sqrt(n); + +mprintf('\nValue of sigma_x=%f',sigma_x); + +Cp=(USL-LSL)/6/sigma; +Cpk=min(xbar-LSL,USL-xbar)/3/sigma; + +mprintf('\nCp=%f and Cpk=%f',Cp,Cpk) diff --git a/1202/CH21/EX21.5/21_5.sce b/1202/CH21/EX21.5/21_5.sce new file mode 100755 index 000000000..8b0c66a96 --- /dev/null +++ b/1202/CH21/EX21.5/21_5.sce @@ -0,0 +1,72 @@ +clear +clc + +//Example 21.5 +disp('Example 21.5') + +//data +x=[ 17.7 1380. + 23.6 1458. + 13.2 1322. + 25.2 1448. + 13.1 1334. + 27.8 1485. + 29.8 1503. + 9. 1540. + 14.3 1341. + 26. 1448. + 23.2 1426. + 22.8 1417. + 20.4 1384. + 17.5 1380. + 18.4 1396. + 16.8 1345. + 13.8 1349. + 19.4 1398. + 24.7 1426. + 16.8 1361. + 14.9 1347. + 27.6 1476. + 26.1 1454. + 20. 1393. + 22.9 1427. + 22.4 1431. + 19.6 1405. + 31.5 1521. + 19.9 1409. + 20.3 1392.]; + + +T=mean(x,'r'); +s=sqrt(variance(x,'r')); + +UCL=T+3*s; +LCL=T-3*s; + +p=size(x,1) + +subplot(2,1,1); +plot2d(repmat(UCL(1),1,p)); +plot2d(repmat(LCL(1),1,p)); +plot2d(repmat(T(1),1,p)); +plot2d(x(:,1),style=-1,rect=[0,0,32,40]) +xtitle('Example 21.4','Sampling number','BOD (mg/L)') + + +subplot(2,1,2); +plot2d(repmat(UCL(2),1,p)); +plot2d(repmat(LCL(2),1,p)); +plot2d(repmat(T(2),1,p)); +plot2d(x(:,2),style=-1,rect=[0,1200,32,1600]) +xtitle('','Sampling number','Solids (mg/L)') + +//subplot(3,1,3); +scf() +plot2d(x(8,1),x(8,2),style=-3,rect=[0,1200,40,1600]) +plot2d(x(:,1),x(:,2),style=-1,rect=[0,1200,40,1600]) +legend("Sample #8",position=4) +xtitle('','BOD (mg/L)','Solids (mg/L)') + +mprintf('\nThe confidence interval for third case is not drawn\n... + because it is beyond the scope of this book') + diff --git a/1202/CH21/EX21.5/21_5a.png b/1202/CH21/EX21.5/21_5a.png Binary files differnew file mode 100755 index 000000000..0ca43a91b --- /dev/null +++ b/1202/CH21/EX21.5/21_5a.png diff --git a/1202/CH21/EX21.5/21_5b.png b/1202/CH21/EX21.5/21_5b.png Binary files differnew file mode 100755 index 000000000..c079d1388 --- /dev/null +++ b/1202/CH21/EX21.5/21_5b.png diff --git a/1202/CH21/EX21.6/21_6.png b/1202/CH21/EX21.6/21_6.png Binary files differnew file mode 100755 index 000000000..385f3c3b8 --- /dev/null +++ b/1202/CH21/EX21.6/21_6.png diff --git a/1202/CH21/EX21.6/21_6.sce b/1202/CH21/EX21.6/21_6.sce new file mode 100755 index 000000000..850239d60 --- /dev/null +++ b/1202/CH21/EX21.6/21_6.sce @@ -0,0 +1,60 @@ +clear +clc + +//Example 21.6 +disp('Example 21.6') + +//data +x=[ 17.7 1380. + 23.6 1458. + 13.2 1322. + 25.2 1448. + 13.1 1334. + 27.8 1485. + 29.8 1503. + 9. 1540. + 14.3 1341. + 26. 1448. + 23.2 1426. + 22.8 1417. + 20.4 1384. + 17.5 1380. + 18.4 1396. + 16.8 1345. + 13.8 1349. + 19.4 1398. + 24.7 1426. + 16.8 1361. + 14.9 1347. + 27.6 1476. + 26.1 1454. + 20. 1393. + 22.9 1427. + 22.4 1431. + 19.6 1405. + 31.5 1521. + 19.9 1409. + 20.3 1392.]; + + +n=1; +N=size(x,1); +T=mean(x,'r'); +//For our example n=1 because each measurement is a subgroup +S=mvvacov(x); +//Note that mvvacov calculates covariance with denominator N, while +//variance caluclates with denominator N-1, hence diagonal entry of mvvacov does not +//match with variance calculated manually for each vector +//As per wikipedia the book is wrong and for covariance matrix we should +//use N-1 but here we follow the book +Tsquare=zeros(N,1); +for k=1:N + Tsquare(k)=n*(x(k,:)-T)*inv(S)*(x(k,:)-T)'; +end + +UCL=11.63; + +plot(repmat(UCL,1,N),color='black'); +plot(Tsquare,'+') +legend("UCL 99% confidence limit") +xtitle("Example 21.6","Sample number","$T^2$") |