Time-Weighted Charts

Time-weighted control charts accumulate information from multiple consecutive observations to detect sustained shifts in the process mean that Shewhart charts may miss. A Shewhart chart evaluates each point in isolation against 3-sigma limits and is highly sensitive to large, abrupt shifts. Time-weighted charts sacrifice that sensitivity to sudden large changes in exchange for much earlier detection of small, gradual drifts — the kind that frequently occur in process degradation scenarios such as tool wear, reagent depletion, or thermal drift.

The Numerics.NET SPC library provides two time-weighted chart types: the Exponentially Weighted Moving Average (EWMA) chart and the Cumulative Sum (CUSUM) chart. Both are available through dedicated chart classes: EwmaChart and CusumChart.

When to use time-weighted charts

Time-weighted charts are most valuable in the following situations:

  • You need to detect a mean shift of 1.0 to 1.5 sigma quickly, and waiting for a Shewhart chart to signal (which may take many samples) is operationally unacceptable.

  • The process is known to drift gradually rather than shift abruptly. Examples include slow tool wear, gradual reagent depletion, and temperature creep.

  • Individual measurements are highly variable (low signal-to-noise ratio) so that individual-observation Shewhart charts produce many false alarms while missing the underlying trend.

Time-weighted charts are complements to Shewhart charts, not replacements. In a rigorous monitoring programme, a Shewhart chart catches large immediate upsets while an EWMA or CUSUM chart monitors for drift. Running both simultaneously is common in regulated industries.

EWMA chart

The EWMA chart replaces each observation with an exponentially weighted moving average that gives more weight to recent observations and progressively less weight to older ones. The weighting is controlled by a smoothing constant λ. A smaller λ weights history more heavily and is more sensitive to small shifts but slower to respond to large ones; a larger λ approaches the behaviour of a Shewhart chart.

Parameters

The EWMA chart is controlled by two parameters configured via EwmaChartOptions:

Lambda (λ)

The smoothing constant, in the range (0, 1]. The default value is approximately 0.2, which is the conventional starting point for detecting shifts of about 1 sigma. Typical values are 0.05–0.30.

  • λ = 0.05–0.10: sensitive to very small shifts (≈ 0.5σ); slow to react to large upsets.

  • λ = 0.20: balanced; effective for detecting 1σ shifts.

  • λ = 0.40–1.00: similar to a Shewhart chart; suitable for large shifts only.

Width (L)

The sigma multiplier used to set the control limits. The default value is 3. For small λ, the EWMA control limits are narrower than a 3-sigma Shewhart band because the variance of the weighted average is reduced; the library accounts for this in the limit computation automatically. Reducing L (e.g. to 2.7 or 2.5) increases sensitivity but also increases the false-alarm rate.

Initialization

The EWMA statistic is initialised at the process mean (the grand mean of the input observations). Starting at the mean rather than at the first observation avoids an artificial transient in the early chart values. This is the standard approach for Phase II (ongoing monitoring) EWMA charts.

If you are applying the chart in Phase I (retrospective analysis where the mean is not yet known), the initialisation at the sample mean is still appropriate because the chart is symmetric around the grand mean.

Outputs

The EwmaChart exposes the following members after Analyze():

Property

Type

Description

Values

Vector<double>

The EWMA statistic at each time step, one value per observation.

CenterLine

double

The process mean used as the reference value and the starting point of the EWMA recursion.

UpperControlLimits

Vector<double>

Pointwise upper control limits, one per observation. These vary during the warm-up period (approximately the first 1/λ observations) while the EWMA variance converges. Always render as a curve, not as a horizontal line.

LowerControlLimits

Vector<double>

Pointwise lower control limits, mirror of UpperControlLimits about the center line.

Lambda

double

The smoothing constant λ in (0, 1]. Available for display or serialization.

Width

double

The sigma multiplier used to set control limits (default 3.0). Available for display or serialization.

  Note

The control limits on an EWMA chart represent the steady-state ±Lσ band for the exponentially weighted statistic, not for the original measurements. A point that falls outside the EWMA limits does not mean the original observation was extreme; it means the accumulation of recent observations is inconsistent with the reference mean.

The following code example demonstrates computing an EWMA chart:

C#
double[] data = {
    10.5, 11.2, 10.8, 11.5, 10.3, 11.8, 10.1, 11.4,
    10.9, 11.1, 10.6, 11.3, 10.7, 11.0, 10.4
};

// lambda = 0.2 is a common choice for detecting shifts of ~1-2 sigma
EwmaChart chart = new EwmaChart(
    Vector.Create(data),
    new EwmaChartOptions { Lambda = 0.2 });
chart.Analyze();

Console.WriteLine($"EWMA: CL={chart.Series.CenterLine:F4}");
Vector<double> pts  = chart.Series.Values;
Vector<double> ucls = chart.Series.UpperControlLimits;
for (int i = 0; i < pts.Count; i++)
    Console.WriteLine(
        $"  [{i}] EWMA={pts[i]:F4} " +
        $"UCL={ucls[i]:F4}");

CUSUM chart

The CUSUM (Cumulative Sum) chart accumulates deviations from a target mean, making it highly sensitive to sustained departures in either direction. Unlike the EWMA, which uses an exponential memory that down-weights old observations, the CUSUM explicitly tests whether the running sum of deviations has exceeded a threshold, giving it near-optimal sequential detection properties for a shift of known size.

The library implements the two-sided tabular CUSUM, which maintains separate statistics for upward and downward shifts:

  • C+ (cumulative sum high) — accumulates evidence of an upward shift. Available as UpperCusumValues.

  • C (cumulative sum low) — accumulates evidence of a downward shift. Available as LowerCusumValues.

Parameters

The CUSUM chart has two key parameters:

Reference value (k)

Also called the allowance or slack parameter. It defines the size of shift (in sigma units) that the CUSUM is tuned to detect. Deviations smaller than k per observation do not accumulate in the statistic. The typical value is half the shift size you want to detect: to detect a 1σ shift quickly, set k = 0.5. For a 2σ shift, k = 1.0.

Decision interval (h)

The threshold at which the cumulative sum triggers a signal. The CUSUM signals when C+ or C exceeds h. The typical value is h = 4 or h = 5 (in sigma units), yielding an Average Run Length (ARL) of approximately 465 under the in-control hypothesis.

The conventional default parameterisation for detecting a 1σ shift with ARL ≈ 465 in-control is k = 0.5 and h = 4 (or equivalently k = 0.5σ and h = 4σ in actual measurement units when sigma is estimated from the data).

Outputs

The CusumChart exposes the following members after Analyze():

Property

Type

Description

UpperCusumValues

Vector<double>

Array of C+ values, one per observation. These are always non-negative. Render as a series starting at zero.

LowerCusumValues

Vector<double>

Array of C values (positive magnitudes), one per observation. These are always non-negative. Render as a series starting at zero.

DecisionInterval

double

The h parameter. A signal occurs whenever C+ or C exceeds this value. Render as a horizontal decision line at this value on both cumulative sum series.

ReferenceValue

double

The k parameter used. Deviations smaller than k per observation do not accumulate in the statistic.

Target

double

The reference mean μ0. The CUSUM accumulates deviations from this value.

Sigma

double

The sigma value used to standardize observations before applying the reference value k.

The conventional rendering shows C+ and C as two separate series, both starting at zero, with a horizontal decision line at h. When either series crosses h, a signal is present. The series resets to zero after a signal in some implementations, but the library returns the full unreset cumulative sums so that you can choose whether to reset and where.

The following code example demonstrates computing a CUSUM chart:

C#
double[] data = {
    10.5, 11.2, 10.8, 11.5, 10.3, 11.8, 10.1, 11.4,
    10.9, 11.1, 10.6, 11.3, 10.7, 11.0, 10.4
};

// Reference value k=0.5 to detect 1-sigma shifts; decision interval h=5
CusumChart chart = new CusumChart(
    Vector.Create(data),
    new CusumChartOptions { ReferenceValue = 0.5, DecisionInterval = 5.0 });
chart.Analyze();

Console.WriteLine($"CUSUM decision interval: {chart.DecisionInterval:F4}");
Vector<double> upper = chart.UpperCusumValues;
Vector<double> lower = chart.LowerCusumValues;
for (int i = 0; i < upper.Length; i++)
    Console.WriteLine(
        $"  [{i}] C+={upper[i]:F4} " +
        $"C-={lower[i]:F4}");

Do not apply Nelson or Western Electric run rules to EWMA or CUSUM statistics

Nelson rules and Western Electric rules were designed for Shewhart chart statistics, where successive plotted points are approximately independent. EWMA and CUSUM statistics are by design serially correlated — each value depends on all preceding values. Applying run rules to them produces meaningless results:

  • Rules based on consecutive points on the same side of the centre line (N2, N3) will fire constantly even on an in-control EWMA because the smoothing introduces strong positive autocorrelation.

  • Rules based on proximity to sigma bands (N5, N6, N7, N8) compare against ±1σ and ±2σ of the original measurements, not of the EWMA statistic, making the comparisons statistically invalid.

  Caution

The library does not prevent you from passing EWMA or CUSUM data to a rule evaluator, but doing so will produce false signals and is statistically incorrect. For time-weighted charts, use only the decision-interval threshold (for CUSUM) or the steady-state control limits (for EWMA) to identify out-of-control conditions.

For the correct use of run rules with Shewhart charts, see rule evaluation and stability interpretation.

See Also