Wednesday, September 4, 2013

Results: Monte Carlo Simulation of Acceptance Sampling Plan


I have been meaning to do this for personal reference so it feels good to finally have the results. I'm posting it here for everyone's reference and for my future me since I'm sure I would misplace the file later so to make sure I could at least search it on the internet, here it goes.
------------------------------------------------------

Monte Carlo Simulation of Acceptance Sampling Plan

Background:
Sometimes people get confused why their acceptance sampling plan somehow did not capture a defective item and was shipped to the customer. Here is my take on that matter.

Objective:
To examine using Monte Carlo simulation approach the performance of attribute acceptance sampling plan given batch size of 3200 items, sample size of 125 (MIL-STD-105E: General Inspection Level 2, AQL = 0.1).

Methods:
1. Random numbers were generated using SAS's JMP random number utility. 1,000 columns each having 3200 rows were generated containg a random events pass/fail that follows a Bernoulli distribution with parameter P. This generated table would represent the Population Data where each column representing a distinct period in time.

2. From the generated table above, a random sample of 125 rows will be taken. Each row will be then summarized as either containing a "fail" entry or not. For those columns where "fail" were sampled, a judgment of "batch failed" will be given. For those columns where "fail" were not sampled, a judgement of "batch passed" will be given.

3. Of the interest of this simulation is the examine the response of percent batch_failure as a function of the Bernoulli distribution parameter P.

4. The simulation would be run for the following Bernoulli distribution parameter P = { 0.0001, 0.0005, 0.001, 0.005, 0.01, 0.05, 0.1}. For each value of P, three runs would be made to be able to have a feel on the standard deviation of the results.

Results:
Here are the results of the Simulation
Screen Effectiveness Results
(Percent Trapped* by the Sampling Plan given True Defective Level P):
P *********  Trial1 *********  Trial2 *********   Trial3
0.0001 *********  0.8% *********  1.4% *********  .5%
0.0005 *********  5.7% *********  6.1% *********  5.3%
0.001 *********  12.6% *********  12% *********  10.9%
0.005 *********  49% *********  45.8% *********   47.3%
0.01 *********  71.4% *********  70.7% *********  72.3%
0.05 *********  99.8% *********  99.9% *********  100%
AQL= 0.1 ********  100% ********  100% ********  100%
*(This means Escapee = 100% - Percent Trapped)


Conclusion:
As has been mentioned many times in several threads in this Forum, Acceptance Sampling assures only that no more than a level P = AQL would reach the customer. Below that level of P, just live with the fact that escapees are inevitable.


Reference:
JMP Code that was used to Generate the Results
dt = New Table("Population Data");
p = 0.0001;     //--->You can change this value
i = 1;
fail=0;
end_column = 1000; //----->I will be generating 1000 columns of random numbers
For( i = 1, i <= end_column, i++,
dt << New Column( Char( i ), formula( If( Random Uniform() < ::p, 1, 0 ) ) )
); //---> 1 means Defective, 0 means Good


dt << add rows( 3200 );       //------------->Each column would have 3200 rows
dt_samples = dt << Subset( Output Table( "Samples" ), Sample Size( 125 ) );

j=1;
For( j = 1, j <= end_column, j++,
if(
Col Max( column(dt_samples,j))>0, fail=fail+1,print(fail)
//Note: If I see at least 1 Defective, the sampling plan fails the batch
)
);

print("There are " ||  char(fail) || " samples that failed. That is "||char(round(100*fail/end_column,1))|| "% failure rate.");

No comments:

Post a Comment

 
Custom Search