You are here: Symbol Reference > StatControlCharts Namespace > Functions > StatControlCharts.QCWestgardRules Function
Stats Master VCL
ContentsIndex
PreviousUpNext
StatControlCharts.QCWestgardRules Function

Compares values agains Westgard rules.

Pascal
procedure QCWestgardRules(const Data: TVec; const OutControl: TVec; dataMean: double; dataSigma: double);
Parameters 
Description 
Data 
Data to-be-checked with Westgard rules. 
OutControl 
Vector storing each point status. If point(i) is out-of-control, then OutControl.Values[i] will be greater than zero (see explanation above). 
dataMean 
In most cases equal to data mean, but you can specify any value. 
dataSigma 
In most cases equal to data standard deviation, but you can specify any value. 

Data individual values are tested to determine if they are in, or out, of control using a set of five rules called the Westgard rules. These rules indicate which points are out-of-control. The Westgard rules are (see www.westgard.com/mltirule.htmfor details):

Description 
Rule 
1S3 
One value beyond three sigma from the mean. 
1S2 
One value beyond two sigma from the mean. 
2S2 
Two consecutive values either greater than, or less than, two sigma from the mean. 
RS4 
A difference between consecutive values greater than four sigma. 
41S 
Four consecutive values greater than, or less than, one sigma from the mean. 
10X 
Ten consecutive values all greater than, or less than, the mean. 

For each point several rules can be violated at the same time. Each Westgard rule violation has different value:

Rule violated 
Value 
1S3  
1=2^0  
1S2  
2=2^1  
2S2 *  
4=2^2  
RS4  
8=2^3  
4S1  
16=2^4  
10X *  
32=2^5  

For example, if rules 2S2 and 10X were violated, then the sum of violations for point would be 4 + 32 = 36 = 100100.

>Load process data, then check if any points are out-of-control.

Uses MtxExpr, StatControlCharts;
procedure Example;
var data, outofcontrol,indexes: Vector;
begin
  data.LoadFromFile('process_data.vec');
  QCWestgardRules(data,outofcontrol,data.mean,data.stddev);
  // Now find indexes of out-of-control points
  indexes.FindIndexes(outofcontrol,'>',0);
  // indexes.IValues now stores the indices of out-of-control points
end;
#include "MtxExpr.hpp"
#include "MtxExprInt.hpp"
#include "StatControlCharts.hpp"
void __fastcall Example()
{
      sVector data, outofcontrol;
    VectorInt indexes;

    data.LoadFromFile("process_data.vec");
    QCWestgardRules(data,outofcontrol,data.Mean(),data.StdDev());
    // Now find indexes of out-of-control points
      indexes.FindIndexes(outofcontrol,">",0.0);
}
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!