Constructs EWMA Control Chart.
Calculates the Exponential Weighted Moving Average (EWMA) control chart. 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.
Example 1
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: TSample;
UCL, LCL, DrawVec: Vector;
Data: Matrix
Confidence: TSample;
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 "MtxVecCpp.h"
#include "Math387.hpp"
#include "StatControlCharts.hpp"
#include "MtxVecTee.hpp"
#include "StatSeries.hpp"
void __fastcall Example(TLineSeries* Series1, TLineSeries* Series2,
TLineSeries* Series3)
{
Vector ucl,lcl,drawvec;
Matrix data;
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);
}
using Dew.Math;
using Dew.Math.Units;
using Dew.Stats.Units;
namespace Dew.Examples
{
private void Example(Steema.TeeChart.Styles.Line Series1, Steema.TeeChart.Styles.Line Series2,
Steema.TeeChart.Styles.Line Series3)
{
Matrix data = new Matrix(0,0);
Vector lcl = new Vector(0);
Vector ucl = new Vector(0);
double cl;
data.LoadFromFile("ewma_data.vec");
StatControlCharts.EWMAChart(data,drawvec,out cl,ucl,lcl,0.25,0.95);
MtxVecTee.DrawValues(drawvec,Series1,0,1,false);
// Series2 and Series3 are used for displaying control limits.
MtxVecTee.DrawValues(lcl,Series2,0,1,false);
MtxVecTee.DrawValues(ucl,Series3,0,1,false);
}
}
Declaration
Procedure EWMAChart(Data: TMtx; DrawVec: TVec; out CL, UCL, LCL: TSample; r: TSample = 0.3; Confidence: TSample = 0.997);
Description
Calculates the Exponential Weighted Moving Average (EWMA) control chart. In this case UCL and LCL are constant (asymptote) limits. This chart is also known as exponentially smoothed or geometric moving average chart. It evaluates the process level using an exponentially smoothed moving average. Here, by the term exponentially, we mean the procedure by which individual observations or subgroups are given progressively less importance or weight. When compared to the XChart, the EWMA chart is more sensitive to smaller shifts in the process level.The exponentially weighted moving average is defined as
XHat[t] = r*XHat[t] + (1-r)XHat[t-1] ,
where r is a constant and XHat[t] are EWMA chart points. The starting value for the first sample at time t = 1 = XHat[0] is grand mean value.