% Exempel 6-1 i Montgomerys bok. close all hidden % Fontstorlek på xlabe och ylabel FL=12; FT=16; % Titelstorlek X=[% nr Antal defekta 1 12 2 15 3 8 4 10 5 4 6 7 7 16 8 9 9 14 10 10 11 5 12 6 13 17 14 12 15 22 16 8 17 10 18 5 19 13 20 11 21 20 22 18 23 24 24 15 25 9 26 12 27 7 28 13 29 9 30 6 % Justering av maskinen 31 9 32 6 33 12 34 5 35 6 36 4 37 6 38 3 39 7 40 6 41 2 42 4 43 3 44 6 45 5 46 4 47 8 48 5 49 6 50 7 51 5 52 6 53 3 54 5 % Fortsatt mätning. Processen stabil men ej tillräckligt bra 55 8 56 7 57 5 58 6 59 4 60 5 61 2 62 3 63 4 64 7 65 6 66 5 67 5 68 3 69 7 70 9 71 6 72 10 73 4 74 3 75 5 76 8 77 11 78 9 79 7 80 3 81 5 82 2 83 1 84 4 85 5 86 3 87 7 88 6 89 4 90 4 91 6 92 8 93 5 94 6 ]; % n=50; % Provstorleken D1=X(1:30,2); % Vektorn med antalet defekta pm=D1/n; phat=sum(D1)/(n*length(D1)); % % Rita de första 30 proven i Initial Phase figure hold set(gca,'Ylim',[0,0.55]) plot(pm,'.-k','MarkerEdgeColor','b','MarkerFaceColor','b') UCL1=phat+3*sqrt(phat*(1-phat)/n); CL1=phat; LCL1=phat-3*sqrt(phat*(1-phat)/n); plot(pm*0+UCL1) plot(pm*0+LCL1) plot(pm*0+CL1,'--') %ylabel('Andelen avvikande, $\hat{p}$','Interpreter','Latex','FontSize',FL) ylabel('Andelen avvikande, p','FontSize',FL) xlabel('Provnummer','FontSize',FL) title('Exempel 6-1, Initial Phase','FontSize',FT) text(1,UCL1,['Försöks UCL =',sprintf('%0.4g',UCL1)],'Verticalalignment','Bottom') text(1,LCL1,['Försöks LCL =',sprintf('%0.4g',LCL1)],'Verticalalignment','Bottom') % Rita de första 30 proven. Markera punkter utanför och räkna om % styrgränserna. figure hold set(gca,'Ylim',[0,0.55]) plot(pm,'.-k','MarkerEdgeColor','b','MarkerFaceColor','b') NC=find(pm>UCL1); HA=plot(NC,pm(NC),'or','LineWidth',2,'MarkerSize',10) D1R=D1; D1R(NC)=[]; phat=sum(D1R)/(n*length(D1R)); UCL1R=phat+3*sqrt(phat*(1-phat)/n); CL1R=phat; LCL1R=phat-3*sqrt(phat*(1-phat)/n); plot(pm*0+UCL1R) plot(pm*0+LCL1R) plot(pm*0+CL1R,'--') %ylabel('Andelen avvikande, $\hat{p}$','Interpreter','Latex','FontSize',FL) ylabel('Andelen avvikande, p','FontSize',FL) xlabel('Provnummer','FontSize',FL) title('Exempel 6-1, Initial Phase','FontSize',FT) text(1,UCL1R,['Reviderad UCL =',sprintf('%0.4g',UCL1R)],'Verticalalignment','Bottom') text(1,LCL1R,['Reviderad LCL =',sprintf('%0.4g',LCL1R)],'Verticalalignment','Bottom') text(NC(1),pm(NC(1))+0.02,{'New','Material'},'HorizontalAlignment','Center','Verticalalignment','Bottom') text(NC(2),pm(NC(2))+0.02,{'New','Operator'},'HorizontalAlignment','Center','Verticalalignment','Bottom') % tar med 24 mätningar figure hold set(gca,'Ylim',[0,0.55]) D2=X(1:54,2); pm=D2/n; plot(pm,'.-k','MarkerEdgeColor','b','MarkerFaceColor','b') HA=plot(NC,pm(NC),'or','LineWidth',2,'MarkerSize',10) plot(pm*0+UCL1R) plot(pm*0+LCL1R) plot(pm*0+CL1R,'--') %ylabel('Andelen avvikande, $\hat{p}$','Interpreter','Latex','FontSize',FL) ylabel('Andelen avvikande, p','FontSize',FL) xlabel('Provnummer','FontSize',FL) title('Exempel 6-1, Initial Phase','FontSize',FT) text(1,UCL1R,['UCL =',sprintf('%0.4g',UCL1R)],'Verticalalignment','Bottom') text(1,LCL1R,['LCL =',sprintf('%0.4g',LCL1R)],'Verticalalignment','Bottom') text(NC(1),pm(NC(1))+0.02,{'New','Material'},'HorizontalAlignment','Center','Verticalalignment','Bottom') text(NC(2),pm(NC(2))+0.02,{'New','Operator'},'HorizontalAlignment','Center','Verticalalignment','Bottom') % Rita upp med nya gränser baserat på prov 31- 54 D2=X(31:54,2); phat=sum(D2)/(n*length(D2)); UCL2=phat+3*sqrt(phat*(1-phat)/n); CL2=phat; LCL2=phat-3*sqrt(phat*(1-phat)/n); figure hold set(gca,'Ylim',[0,0.55]) D2=X(1:54,2); pm=D2/n; plot(pm,'.-k','MarkerEdgeColor','b','MarkerFaceColor','b') HA=plot(NC,pm(NC),'or','LineWidth',2,'MarkerSize',10) plot(1:30,(1:30)*0+UCL1R) plot(1:30,(1:30)*0+CL1R,'--') plot(1:30,(1:30)*0+LCL1R) % De nya gränserna plot(30:54,(30:54)*0+UCL2) plot(31:54,(31:54)*0+CL2,'--') %plot(31:54,(31:54)*0+LCL2) plot([30 30],[UCL1R UCL2]) %ylabel('Andelen avvikande, $\hat{p}$','Interpreter','Latex','FontSize',FL) ylabel('Andelen avvikande, p','FontSize',FL) xlabel('Provnummer','FontSize',FL) title('Exempel 6-1, Initial Phase','FontSize',FT) text(1,UCL1R,['UCL =',sprintf('%0.4g',UCL1R)],'Verticalalignment','Bottom') text(1,LCL1R,['LCL =',sprintf('%0.4g',LCL1R)],'Verticalalignment','Bottom') text(32,UCL2,['UCL =',sprintf('%0.4g',UCL2)],'Verticalalignment','Bottom') text(32,0,['LCL =',sprintf('%0.4g',0)],'Verticalalignment','Bottom') %text(1,LCL2,['LCL =',sprintf('%0.4g',LCL1R)],'Verticalalignment','Bottom') text(NC(1),pm(NC(1))+0.02,{'New','Material'},'HorizontalAlignment','Center','Verticalalignment','Bottom') text(NC(2),pm(NC(2))+0.02,{'New','Operator'},'HorizontalAlignment','Center','Verticalalignment','Bottom') % Phase 2 figure hold set(gca,'Ylim',[0,0.55]) D3=X(1:94,2); pm=D3/n; plot(pm,'.-k','MarkerEdgeColor','b','MarkerFaceColor','b') HA=plot(NC,pm(NC),'or','LineWidth',2,'MarkerSize',10) plot(1:30,(1:30)*0+UCL1R) plot(1:30,(1:30)*0+CL1R,'--') plot(1:30,(1:30)*0+LCL1R) % De nya gränserna plot(30:94,(30:94)*0+UCL2) plot(31:94,(31:94)*0+CL2,'--') %plot(31:54,(31:54)*0+LCL2) plot([30 30],[UCL1R UCL2]) %ylabel('Andelen avvikande, $\hat{p}$','Interpreter','Latex','FontSize',FL) ylabel('Andelen avvikande, p','FontSize',FL) xlabel('Provnummer','FontSize',FL) title('Exempel 6-1, Phase II','FontSize',FT) text(1,UCL1R,['UCL =',sprintf('%0.4g',UCL1R)],'Verticalalignment','Bottom') text(1,LCL1R,['LCL =',sprintf('%0.4g',LCL1R)],'Verticalalignment','Bottom') text(32,UCL2,['UCL =',sprintf('%0.4g',UCL2)],'Verticalalignment','Bottom') text(32,0,['LCL =',sprintf('%0.4g',0)],'Verticalalignment','Bottom') %text(1,LCL2,['LCL =',sprintf('%0.4g',LCL1R)],'Verticalalignment','Bottom') text(NC(1),pm(NC(1))+0.02,{'New','Material'},'HorizontalAlignment','Center','Verticalalignment','Bottom') text(NC(2),pm(NC(2))+0.02,{'New','Operator'},'HorizontalAlignment','Center','Verticalalignment','Bottom') % Ritar OC-kurva för sista nivnåerna (Exakt) figure hold p=0:0.001:0.5; BETA=binocdf(n*UCL2, n, p)-binocdf(n*LCL2, n, p); plot(p,BETA) plot([UCL2 UCL2 0], [0 binocdf(n*UCL2, n, UCL2)-binocdf(n*LCL2, n, UCL2) binocdf(n*UCL2, n, UCL2)-binocdf(n*LCL2, n, UCL2)],'r')