Hi all,
studying for CQE here and I have some questions about OC curves for doubling sampling plans I understand single sampling plans well and even modeled it matlab just fine.
However, shifting to a double sampling plan, I found that the book did a horrible job describing it as seen in the attachment.
so I did some googlies and found a better source that made MORE sense to me as seen bin the attachment.
but when I model it, I can't seem to get the right curve (See last attachment)
I spent a few hours and still can't crack this. I think it might be due to the double summation
Lets say I had sigma_from1_to3 (y) * sigma_from 1_to_3_(x)....the way I'm calculating this in matlab (See below) is like this
y1 *( x1 + x2 + x3) + y2 *( x1 + x2 + x3) + y3 *( x1 + x2 + x3)
Is that right? Conceptually it is: I'm assessing all different probabilities, of accepting a certain # of defectives in the second sample, relative to the first.
Any help?
Code:
clear all
close all
n1=50
ac1=0
re1=3
n2=75
ac2=3
re2=4
p=[0:.001:.2]
%% this is right for sure Pacceptance if NCR <= ac1
PaTotal=[]
for d1 = 0:ac1
MaxCombos = ...
(factorial(n1) ./ (factorial(d1) .* factorial(n1-d1)))
Pa1array=[]
for ii = 1:length(p)
Pa1_Dconstant_foraPvalue = p(ii).^d1 .* (1-p(ii)).^(n1-d1);
Pa1array = [Pa1array; Pa1_Dconstant_foraPvalue];
end
Pa1 = MaxCombos .*Pa1array;
PaTotal=[PaTotal Pa1];
end
Pa1Final = sum(PaTotal,2)
figure(1)
% pa1plot=plot(Pa1Final,'-xg')
%%
Pa1Pa2Total=[];
Pa2Total=[]
for d1_1 = ac1+1:re1-1
MaxCombos = ...
(factorial(n1) ./ (factorial(d1_1) .* factorial(n1-d1_1)))
Pa1array=[]
for ii = 1:length(p)
Pa1_Dconstant_foraPvalue = p(ii).^d1_1 .* (1-p(ii)).^(n1-d1_1);
Pa1array = [Pa1array; Pa1_Dconstant_foraPvalue];
end
Pa1_1 = MaxCombos .*Pa1array;
for d2=0:ac2-d1_1
MaxCombos = ...
(factorial(n2) ./ (factorial(d2) .* factorial(n2-d2)))
Pa2array=[];
for jj = 1:length(p)
Pa2_Dconstant_foraPvalue = p(jj).^d2 .* (1-p(jj)).^(n2-d2);
Pa2array = [Pa2array; Pa2_Dconstant_foraPvalue];
end
Pa2 = MaxCombos .* Pa2array;
Pa2Total=[Pa2Total Pa2];
end
Pa2Summed = sum(Pa2Total,2)
Pa1Pa2 = Pa1_1.*Pa2Summed;
Pa1Pa2Total =[Pa1Pa2Total Pa1Pa2];
end
Pa1Pa2Final = sum(Pa1Pa2Total,2)
hold on, plot(p,Pa1Pa2Final)
plot(p,Pa1Final,'r')
plot(p,Pa1Final+Pa1Pa2Final,'k')
got it =) if you immediately break it up into 2 quick for loops and not iterate it like we'd write it, it is much simpler and i get the right answer. the code is also a LOT more cleaner...