Variables Charts
Variables control charts are used when you have a continuous numeric measurement for each unit or sample, such as a dimension, a weight, a cycle time, or a temperature. They monitor both the process location (mean) and process spread (variation) simultaneously, giving you earlier and more precise signals than attribute charts when the underlying data support them.
The Numerics.NET SPC library provides three variables chart types: the Individuals–Moving Range (I‑MR) chart for individual observations, and the XBar‑R and XBar‑S charts for subgrouped data. Each is described in detail below.
Individuals–Moving Range (I‑MR) chart
The I‑MR chart is appropriate when only one measurement is taken per time period, when subgrouping is not feasible, or when the process cycle time is long enough that consecutive observations are approximately independent. Common applications include batch chemical processes, daily or weekly production totals, and any situation where the cost of measurement limits you to a single observation per sampling interval.
The chart set consists of two charts rendered together:
The Individuals chart plots each observation against control limits derived from the average moving range.
The Moving Range chart plots the absolute difference between consecutive observations. It has only an upper control limit (moving ranges are non-negative).
Inputs
The primary input is the ordered sequence of individual measurements. The library accepts either a Vector<double> or a ReadOnlySpan<double>. The observations must be in the chronological order in which they were produced.
The optional movingRangeWidth parameter (default 2) specifies how many consecutive observations are included in each moving range computation. A width of 2 computes the range between each observation and its immediate predecessor. Increasing the width to 3 or 4 uses a wider span and may be appropriate when individual measurements are known to be correlated. The minimum meaningful width is 2; the library requires at least movingRangeWidth observations to produce any moving range values.
Sigma estimator options
The within-process sigma used to compute control limits can be estimated in two ways, controlled by the SigmaEstimator enumeration:
- MovingRange (default)
Estimates sigma from the average moving range using the standard unbiasing constant
. This is the classical Shewhart estimator for individual observations and is recommended in most circumstances because it is robust to gradual process drift.- OverallStandardDeviation
Estimates sigma from the overall sample standard deviation of all observations. This estimator is sensitive to between-subgroup variation and will produce wider control limits if the process has shifted. Use it only when the classical estimator is known to be inappropriate for your application.
Outputs
The IndividualsMovingRangeChartSet exposes the following series after Analyze():
Property | Type | Description |
|---|---|---|
Chart data for the Individuals chart, including the plotted values, center line, upper control limit, and lower control limit. | ||
Chart data for the Moving Range chart. The lower control limit is always zero; only the upper control limit is meaningful. |
See result model and rendering semantics for guidance on consuming these properties in a rendering layer.
The following code example demonstrates computing an I‑MR chart:
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
};
IndividualsMovingRangeChartSet chart =
new IndividualsMovingRangeChartSet(Vector.Create(data));
chart.Analyze();
FixedLimitSeries iSeries = chart.IndividualsSeries;
FixedLimitSeries mrChart = chart.MovingRangesSeries;
Console.WriteLine($"I chart: CL={iSeries.CenterLine:F4} " +
$"UCL={iSeries.UpperControlLimit:F4} " +
$"LCL={iSeries.LowerControlLimit:F4}");
Console.WriteLine($"MR chart: CL={mrChart.CenterLine:F4} " +
$"UCL={mrChart.UpperControlLimit:F4}");XBar‑R chart
The XBar‑R chart is used when measurements are collected in rational subgroups of fixed or near-fixed size and the subgroup size is small, typically between 2 and 8. It is the most widely used Shewhart chart in manufacturing because subgrouping averages out short-term noise on the XBar chart while the Range chart detects changes in spread.
The chart set consists of:
The XBar chart, which plots the subgroup mean against control limits derived from the average subgroup range.
The Range chart, which plots the subgroup range and monitors process spread.
Inputs
XBarRChartSet accepts a Matrix<double> in which each row represents one rational subgroup and each column represents one measurement position within the subgroup. The rows must be in chronological order. The number of columns defines the subgroup size, which must be at least 2.
XBarRChartSet additionally accepts:
A flat ReadOnlySpan<double> paired with an integer subgroupSize — the library partitions the span into equal-sized subgroups.
A flat ReadOnlySpan<double> paired with a ReadOnlySpan<int> of group identifiers — each observation is assigned to the subgroup indicated by the corresponding ID.
A Vector<double> paired with an IGrouping — the grouping object assigns observations to subgroups. All subgroups must have equal size for XBar‑R; an ArgumentException is thrown otherwise.
A ListVector<double> whose elements are the individual subgroups. All subgroups must have equal size for XBar‑R; the library validates this and throws an ArgumentException on mismatch.
The XBar‑R chart is designed for subgroup sizes of 2 to 8. For subgroup sizes greater than 8, the range is a less efficient estimator of spread than the standard deviation, and the XBar‑S chart should be used instead.
Outputs
The XBarRChartSet exposes the following series after Analyze():
Property | Type | Description |
|---|---|---|
Chart data for the subgroup means, including center line (grand mean) and symmetric control limits. | ||
Chart data for the subgroup ranges. The lower control
limit is zero for subgroup sizes less than 7; for
sizes 7 and 8 it takes a small positive value derived
from the |
The following code example demonstrates computing an XBar‑R chart:
// 5 subgroups of size 4
double[,] data = {
{ 9.8, 10.2, 10.0, 10.1 },
{ 10.3, 9.9, 10.1, 10.2 },
{ 9.7, 10.4, 9.8, 10.0 },
{ 10.1, 10.0, 9.9, 10.3 },
{ 10.2, 9.8, 10.2, 10.1 }
};
Matrix<double> subgroups = Matrix.CopyFrom(data);
XBarRChartSet chart = new XBarRChartSet(subgroups);
chart.Analyze();
Console.WriteLine($"XBar: CL={chart.MeansSeries.CenterLine:F4} " +
$"UCL={chart.MeansSeries.UpperControlLimit:F4}");
Console.WriteLine($"R: CL={chart.RangesSeries.CenterLine:F4} " +
$"UCL={chart.RangesSeries.UpperControlLimit:F4}");XBar‑S chart
The XBar‑S chart replaces the range with the sample standard deviation as the measure of within-subgroup spread. It is preferred over XBar‑R when:
The subgroup size is 9 or larger, because the standard deviation is a more efficient estimator of sigma than the range for large samples.
The subgroup size varies from subgroup to subgroup. The XBar‑S chart accommodates variable subgroup sizes naturally.
Statistical efficiency is a priority and subgroup sizes are moderate (5 or more) but the additional complexity is accepted.
Inputs
As with XBar‑R, XBarSChartSet accepts a Matrix<double> where each row is a subgroup and each column is a measurement. Variable subgroup sizes are supported through an optional subgroupSizes parameter; if supplied, it specifies the number of valid measurements in each row. Entries beyond the valid count in a row are ignored.
XBarSChartSet additionally accepts the same flat-span, IGrouping, and ListVector input forms described for XBar‑R. Unlike XBar‑R, XBar‑S supports variable subgroup sizes through all these forms.
Outputs
The XBarSChartSet exposes the following series after Analyze():
Property | Type | Description |
|---|---|---|
Chart data for the subgroup means. When subgroup sizes vary, the control limits vary per subgroup because the standard error of the mean depends on n. | ||
Chart data for the subgroup standard deviations. When subgroup sizes are variable, the control limits vary point by point. |
When subgroup sizes vary, render each point with its own pair of limit values; do not draw horizontal limit lines.
The following code example demonstrates computing an XBar‑S chart:
// 5 subgroups of size 10
Matrix<double> subgroups = Matrix.RandomUniform(5, 10, 8.0, 10.0);
XBarSChartSet chart = new XBarSChartSet(subgroups);
chart.Analyze();
Console.WriteLine($"XBar: CL={chart.MeansSeries.CenterLine:F4} " +
$"UCL={chart.MeansSeries.UpperControlLimit:F4}");
Console.WriteLine(
$"S: CL={chart.StandardDeviationsSeries.CenterLine:F4} " +
$"UCL={chart.StandardDeviationsSeries.UpperControlLimit:F4}");Choosing among variables chart types
The following table summarises the selection criteria:
Situation | Recommended chart |
|---|---|
One observation per time period | I‑MR |
Subgroups of fixed size 2–8 | XBar‑R |
Subgroups of fixed size 9 or more | XBar‑S |
Subgroups of variable size | XBar‑S |
Subgroups of size 5–8 and statistical efficiency is a priority | XBar‑S (preferred) or XBar‑R (acceptable) |
For a decision tree that also covers attribute and time-weighted charts, see choosing the right analysis.