File: xshewhartrunsrules.ad.R

package info (click to toggle)
r-cran-spc 1%3A0.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,888 kB
  • sloc: ansic: 22,279; makefile: 2
file content (25 lines) | stat: -rw-r--r-- 529 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

xshewhartrunsrules.ad <- function(mu1, mu0=0, c=1, type="12") {

# Shewhart chart
  if (type=="1") {
    p0 <- pnorm(  3*c, mean=mu1 ) - pnorm( -3*c, mean=mu1)
    ad <- 1/(1-p0)
  }

# ditto with runs rules
  if (type!="1") {
    Q1 <- xshewhartrunsrules.matrix(mu1, c=c, type=type)
    dimQ <- nrow(Q1)
    one <- rep(1, dimQ)
    I   <- diag(1, dimQ)
    arls <- solve(I-Q1, one)

    Q0 <- xshewhartrunsrules.matrix(mu0, c=c, type=type)
    psi <- Re(eigen(t(Q0))$vectors[,1])

    ad <- sum(psi * arls)/sum(psi)
  }

  ad
}