# bp: Box-Pierce-Type Statistic In spc4sts: Statistical Process Control for Stochastic Textured Surfaces

## Description

Compute a Box-Pierce-type (BP) statistic for pixels in a given image. `bp2()` cannot be used for pixels with the boundary problem, but is more efficient than `bp()` for other pixels.

## Usage

 ```1 2``` ```bp(img, i1, i2, w, K = kerMat((w + 1)/2)) bp2(img, i1, i2, w , K = kerMat((w + 1)/2)) ```

## Arguments

 `img` the given image `i1` the row index of the pixel to compute the BP statistic for. `i2` the column index of the pixel to compute the BP statistic for. `w` the dimension of the spatial (square) moving window. Must be an odd number >= 3. `K` the weighted matrix.

## Value

The BP statistic.

## Warning

For pixels with the boundary problem, `bp()` must be used.

## Note

`bp()` is only used in `sms()` for pixels with the boundary problem. It is less efficient than `bp2()` for other pixels.

Anh Bui

## References

Bui, A.T. and Apley., D.W. (2018a) "A Monitoring and Diagnostic Approach for Stochastic Textured Surfaces", Technometrics, 60, 1-13.

`kerMat, spaCov, sms, ad`
 ``` 1 2 3 4 5 6 7 8 9 10``` ```img <- matrix(rnorm(100),10,10) ## for pixels with the boundary problem, e.g., Pixel (5,1), # running bp2(img,5,1,3) will produce an error; instead, use bp() in this case: bp(img,5,1,3) ## for pixels without the boundary problem, e.g., Pixel (5,5), # both can be used, but bp2() is more efficient than bp() bp2(img,5,5,3) bp(img,5,5,3) ```