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

Calculates the Exponential Weighted Moving Average (EWMA) control chart.

Pascal
procedure EWMAChart(const Data: TMtx; const DrawVec: TVec; out CL: double; UCL: TVec; LCL: TVec; r: double = 0.3; Confidence: double = 0.997); overload;
Parameters 
Description 
Data 
Data of grouped responses. Each row contais a response at specific time. It's asumed the rows are in time order. 
DrawVec 
Returns the calculated EWMA chart points. 
CL 
Returns EWMA chart center line. 
UCL 
Returns EWMA chart upper control limits. In this case UCL and LCL are constant (asymptote) limits. 
LCL 
Returns EWMA chart lower control limits. In this case UCL and LCL are constant (asymptote) limits. 
Weighting constant that weights past and current information. If, for example, r=0.3, 70% of the weight will be given to past information and 30% to current information. Typically a r between 0.1 and 0.4 provides a reasonable balance between past and current information and 0.2 is very common in actual practice. 
Confidence 
 

In this case UCL and LCL are not constant, but use an exact formula to calculate control limits for each point. It's worth noting that UCL and LCL values rapidly approach the asymptote value.

TQCSeries, Dew.Stats.Tee.QCSeries

The following code will load data from file and create EWMA chart with r=0.25 and significance 95%:

uses MtxExpr, Math387, StatControlCharts, MtxVecTee, StatSeries;
procedure Example;
var CL: double;
  UCL, LCL, DrawVec: Vector;
  Data: Matrix
  Confidence: double;
begin
  Data.LoadFromFile('ewma_data.mtx');
  EWMAChart(Data,DrawVec,CL,UCL,LCL,0.25,0.95);
  DrawValues(DrawVec,Series1);
  // Series2 and Series3 are line series used for displaying control limits
  DrawValues(UCL,Series2);
  DrawValues(LCL,Series3);
end;
#include "MtxExpr.hpp"
#include "Math387.hpp"
#include "StatControlCharts.hpp"
#include "MtxVecTee.hpp"
#include "StatSeries.hpp"
void __fastcall  Example(TLineSeries* Series1, TLineSeries* Series2,
  TLineSeries* Series3)
{
  sVector ucl,lcl,drawvec;
  sMatrix data;
  double cl;

  data.LoadFromFile("ewma_data.mtx");
  EWMAChart(data,drawvec,cl,ucl,lcl,0.25,0.95);
  DrawValues(drawvec,Series1,0,1,false);
  // Series2 and Series3 are used for displaying control limits.
  DrawValues(lcl,Series2,0,1,false);
  DrawValues(ucl,Series3,0,1,false);
}
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!