I have an assignment with the popular defective machines etc, where we're called to create a function that will calculate the amount of defective articles in a sample n from the Total N.
Keep in mind that we can't distinguish between articles in N1 and N2 as they're all produced together in a pile, and that the probability of producing a defective article is independent to if the previous article was or not defective.
This is the "function" i've come up with, but I'm not sure the logic behind it is correct. I followed this question.
having x1~Bin(1000, 0.05) and x2~Bin(2000,0.02):
N= N1+N2= 3000
amount of defective: d1= N1*p1= 50, d2= N2*p2= 40
probability of defective in N: ptot = d1+d2/N
and then, to calculate the total amount of defective having a random factor to it, I'm using (in R) dtot = rbinom(1, N, ptot).
My questions is the following:
Suppose that N= 1000 ptot= 0.03 dtot~= 33. How does that translate to a sample n=10 from N. Do we consider that being N/10 it still has p_n=ptot and thus d_n ~=3?