- #1
Dustinsfl
- 2,281
- 5
I am trying to simulate the probability of rejecting a good batch for a probability of \(0.94\) using the Binomial Probability Law.
My two cases are
\[
P[k\geq 95] = \sum_{k = 95}^{100}\binom{100}{k}p^k(1 - p)^{100 - k}
\]
and
\[
P[k\geq 98] = \sum_{k = 98}^{100}\binom{100}{k}p^k(1 - p)^{100 - k}
\]
I am not sure with what the question wants me to do so I plotted the both curves from \(p = 0.9\) to \(p = 0.99\).
My two cases are
\[
P[k\geq 95] = \sum_{k = 95}^{100}\binom{100}{k}p^k(1 - p)^{100 - k}
\]
and
\[
P[k\geq 98] = \sum_{k = 98}^{100}\binom{100}{k}p^k(1 - p)^{100 - k}
\]
I am not sure with what the question wants me to do so I plotted the both curves from \(p = 0.9\) to \(p = 0.99\).
Code:
clear all
close all
p = (0.9:0.001:0.99); % probability range
P = zeros(length(p), 1); % pre-allocating P
PP = zeros(length(p), 1); % pre-allocating PP
T = zeros(length(p), 1); % pre-allocating T
TT = zeros(length(p), 1); % pre-allocating TT
% only allowing 5 defective
for i = 1:length(p)
for n = 95:100
T(n, 1) = nchoosek(100, n)*p(i).^n.*(1 - p(i)).^(100 - n);
P(i, 1) = sum(T);
end
end
figure(1)
plot(p, P)
grid on
% only allowing 2 defective
for j = 1:length(p)
for n = 98:100
TT(n, 1) = nchoosek(100, n)*p(j).^n.*(1 - p(j)).^(100 - n);
PP(j, 1) = sum(TT);
end
end
figure(2)
plot(p, PP)
grid on