s-news
[Top] [All Lists]

Xbar control chart

To: s-news@wubios.wustl.edu
Subject: Xbar control chart
From: Riyanto Wibowo <myzptlkrw@yahoo.com>
Date: Mon, 29 Dec 2003 22:39:21 -0800 (PST)
Dear S-news community,
 
As you know, the average run length is a measure performance of a control chart.  And of course you supposedly know, that the ARL for Xbar chart (with 3 sigma) is 370 definitly.  I try to make a function to make a proof about this statement.  But my function's result cannot reach 370.  Is somebody can help me ? I'm really frustated about this problem, because I check my function for more than twenty times and I still don't know what my fault is.  Below is my function (you can copy and paste it to your S-Plus) :
 
function(PS, simulation, replikasi)
{
 xbar <- matrix(0, PS, 1)
 R <- matrix(0, PS, 1)
 xbar1 <- matrix(0, simulation,
  1)
 R1 <- matrix(0, simulation, 1)
 out <- matrix(0, 1, 2)
 RL <- matrix(0, replikasi, 1)
 for(i in 1:PS) {
  x <- round(rnorm(5,
   mean = 10, sd
    = 1), digits
    = 3)
  xbar[i, 1] <- round(
   mean(x), 3)
  R[i, 1] <- max(x) -
   min(x) 
 #print(x)
#print(xbar[i, 1])
#print(R)
 }
#print("RESUME")
 xbarbar <- round(mean(xbar), 3
  ) 
 #print(paste("Xbarbar:", xbarbar))
 Rbar <- round(mean(R), 3) 
 #print(paste("Rbar:", Rbar))
 UCLx <- xbarbar + round((0.577 *
  Rbar), 3)
 LCLx <- xbarbar - round(( 0.577 *
  Rbar), 3)
 print(paste("UCL X bar:", UCLx
  ))
 print(paste("LCL X bar:", LCLx
  ))
 UCLR <- (2.115) * Rbar
 LCLR <- 0 
 #print(paste("UCL R :", UCLR))
#print(paste("LCL R :", LCLR))
 for(j in 1:PS) {
  if((xbar[j, 1] > UCLx |
   xbar[j, 1] <
   LCLx) | (R[j,
   1] > UCLR | R[
   j, 1] < 0)) {
#print(paste("SAMPLE OUT OF CONTROL AT POINT :", j))
   return()
  }
 }
 print("PRELIMINARY SAMPLE ALL IN CONTROL !!!"
  )
 for(k in 1:replikasi) {
#print(paste("REPLIKASI KE :", k))
  s <- 0
  for(l in 1:simulation
   ) {
   y <- rnorm(5,
    mean
     = 10,
    sd = 1
    ) 
 #print(y)
   xbar1[l, 1] <-
    round(
    mean(y
    ),
    digits
     = 3) 
 #print(xbar1[l, 1])
   if(xbar1[l, 1] >
    round(
    UCLx,
    digits
     = 3) |
    xbar1[
    l, 1] <
    round(
    LCLx,
    digits
     = 3)
    ) {
#print(UCLx)
#print(LCLx)
#print(xbar1[l, 1]) #print(R1[l, 1])
    s <- s +
      1
    out[1,
      s] <-
      l 
 #print(paste("OUT AT POINT :", l))
    if(s >
      1)
      {
      RL[k
        ] <-
        out[
        1,
        2] -
        out[
        1,
        1]
  #print(paste("RUN LENGTH KE-", k, ":", RL[k]        ))
      break
    }
   }
  }
 }
 RL
}
PS means Preliminary sample, usually 30 for Xbar chart.
Sim means simulation data (how many data you want to generate in simulation JUST for one chart)
Replikasi means replication (how many chart you want to make a simulation; I usually use 1000)
 
My idea is below :
1. I generate PS (say 30) rnrom data with each PS contain 5 sub samples. For each PS I calculate the average and the range.  When all average and range from PS collected,it follows with the calculation of the average (Xbarbar or X double bar) and the Rbar (average of the range).
2. I use Xbarbar and Rbar to setup the UCL and LCL.  I recheck for my PS.  If one of my PS is out of control, than the function is stop (return).
3.But when all PS is in control, the simulation begin.  I generate sim (e.g. 2000) data JUST for one chart.  If (say data number 300 and 456) is out of control, the function collect the first Run length which 456-300 =156.
4.Step number three is repeated for replikasi (e.g. 1000).  So you will get replikasi run length.
5. The function will result all run length which was collected. You shoud store it in a variable.  The ARL can be obtained by calculate the average of your variable.
Finish.
 
I apologize about my English. I realy realy need your help. Thank you very very much for your attention. THANK YOU.
 
Best regards,
 
Ryan
 


Do you Yahoo!?
Free Pop-Up Blocker - Get it now
<Prev in Thread] Current Thread [Next in Thread>
  • Xbar control chart, Riyanto Wibowo <=