Attribute Charts
Attribute control charts are used when the process output is classified rather than measured. There are two fundamental classification schemes, and selecting the wrong chart for your classification scheme produces statistically incorrect control limits:
Defectives: each inspected unit either passes or fails as a whole (binary outcome). Use P or NP charts.
Defects: each unit is counted for the number of individual nonconformities it contains; one unit can have multiple defects. Use C or U charts.
All four attribute chart types have dedicated chart classes: PChart, NpChart, CChart, and UChart.
P chart: fraction defective
The P chart monitors the proportion (fraction) of defective units in each sample. It is the attribute chart to use when sample sizes vary from period to period, which is common in high-volume inspection where 100% inspection of variable production quantities is performed.
Because the control limits are based on the binomial distribution and the standard error of a proportion depends on n, the control limits are pointwise: each sampling period has its own upper and lower control limit. The limits widen for small samples and narrow for large samples.
Inputs
Provide two parallel Vector<double> arrays of equal length:
Defective counts: the number of defective units found in each sample.
Sample sizes: the total number of units inspected in each sample.
Both vectors must have the same length. Each element of the defective-count vector must be less than or equal to the corresponding element of the sample-size vector.
Outputs
The PChart exposes the following members after Analyze():
Property | Type | Description |
|---|---|---|
Vector<double> | Fraction nonconforming per subgroup (defective count divided by sample size). | |
double | Pooled average fraction nonconforming. Render as a horizontal reference line. | |
Vector<double> | Pointwise upper control limits, one per subgroup. Authoritative for rendering; wider for small samples, narrower for large samples. | |
Vector<double> | Pointwise lower control limits, one per subgroup. May be zero when the binomial lower bound is non-positive. | |
Vector<double> | Sample sizes (n) for each subgroup, parallel to Values. |
The following code example demonstrates computing a P chart:
// Defect counts and sample sizes per subgroup
Vector<double> defects = Vector.Create(
new double[] { 3, 5, 2, 7, 4, 6, 3, 8, 2, 5 });
Vector<double> sampleSizes = Vector.Create(
new double[] { 50, 60, 45, 70, 55, 65, 50, 80, 45, 60 });
PChart chart = new PChart(defects, sampleSizes);
chart.Analyze();
Console.WriteLine($"P chart center line: {chart.Series.CenterLine:F4}");
// Use pointwise vectors for variable-sample P charts
Vector<double> pts = chart.Series.Values;
Vector<double> ucls = chart.Series.UpperControlLimits;
Vector<double> lcls = chart.Series.LowerControlLimits;
for (int i = 0; i < pts.Count; i++)
Console.WriteLine(
$" [{i}] p={pts[i]:F4} " +
$"LCL={lcls[i]:F4} " +
$"UCL={ucls[i]:F4}");NP chart: count of defectives
The NP chart monitors the raw count of defective units per sample rather than the proportion. It is appropriate only when the sample size is constant across all sampling periods. Because it plots a count rather than a proportion, NP charts are sometimes preferred when communicating with operators who find counts more intuitive than fractions.
When sample sizes vary, use the P chart instead. Applying an NP chart to variable sample sizes produces control limits that assume the fixed average sample size for every point, which is incorrect.
Inputs
Provide a single Vector<double> of defective counts and a scalar sample size (the constant n). The sample size must be the same for every sampling period.
Outputs
The NpChart exposes the following members after Analyze():
Property | Type | Description |
|---|---|---|
Vector<double> | Count of nonconforming units per subgroup. | |
double | Average count of nonconforming units. Render as a horizontal reference line. | |
double | Scalar upper 3-sigma control limit. Constant because the NP chart requires a fixed sample size. | |
double | Scalar lower 3-sigma control limit. May be double.NaN when theoretically non-positive. | |
double | The constant sample size used for all subgroups. |
Because the sample size is constant, the center line and control limits are scalar values that can be rendered as horizontal lines.
The following code example demonstrates computing an NP chart:
// Fixed sample size of 100 per subgroup
Vector<double> defects = Vector.Create(
new double[] { 3, 5, 2, 7, 4, 6, 3, 8, 2, 5 });
double sampleSize = 100;
NpChart chart = new NpChart(defects, sampleSize);
chart.Analyze();
Console.WriteLine($"NP chart: CL={chart.Series.CenterLine:F4} " +
$"UCL={chart.Series.UpperControlLimit:F4} " +
$"LCL={chart.Series.LowerControlLimit:F4}");C chart: count of defects
The C chart monitors the total count of defects (nonconformities) observed in a fixed inspection unit. A single unit may contain multiple defects; the C chart counts all of them. Typical applications include surface blemishes on a fixed-area panel, solder defects on a printed circuit board of standard design, or weld inclusions per pipe section of fixed length.
The C chart assumes that defects occur according to a Poisson distribution and that the inspection unit (the area of opportunity) is constant from sample to sample. If the area of opportunity varies, use the U chart instead.
Inputs
Provide a single Vector<double> of defect counts, one element per inspection unit. All elements represent the same fixed opportunity size.
Outputs
The CChart exposes the following members after Analyze():
Property | Type | Description |
|---|---|---|
Vector<double> | Defect counts per inspection unit. | |
double | Average defect count per inspection unit. Render as a horizontal reference line. | |
double | Scalar upper 3-sigma control limit. Constant because the C chart uses a fixed area of opportunity. | |
double | Scalar lower 3-sigma control limit. May be double.NaN when theoretically non-positive. | |
double | The average defect count per inspection unit. Equal to CenterLine. |
Because the area of opportunity is constant, the center line and control limits are scalar values that can be rendered as horizontal lines.
The following code example demonstrates computing a C chart:
// Defect counts per fixed-opportunity inspection unit
Vector<double> defects = Vector.Create(
new double[] { 2, 3, 1, 5, 2, 4, 1, 3, 2, 4 });
CChart chart = new CChart(defects);
chart.Analyze();
Console.WriteLine($"C chart: CL={chart.Series.CenterLine:F4} " +
$"UCL={chart.Series.UpperControlLimit:F4} " +
$"LCL={chart.Series.LowerControlLimit:F4}");U chart: defects per unit with variable opportunity
The U chart monitors the rate of defects per unit when the inspection opportunity (area, length, volume, or time) varies from sample to sample. It divides the defect count by the opportunity size to produce a comparable rate across samples. Typical applications include fabric defects per square metre when roll widths vary, weld defects per metre of weld when weld lengths vary, or software bugs per thousand lines of code across modules of different sizes.
Like the P chart, the U chart produces pointwise control limits because the standard error of a Poisson rate depends on the opportunity size.
Inputs
Provide two parallel Vector<double> arrays:
Defect counts: the total number of defects observed in each sample.
Opportunity sizes: the inspection area, length, or equivalent unit count for each sample. All values must be positive.
Outputs
The UChart exposes the following members after Analyze():
Property | Type | Description |
|---|---|---|
Vector<double> | Defect rates (count divided by opportunity), one value per subgroup. | |
double | Average defects per unit across all subgroups. Render as a horizontal reference line. | |
Vector<double> | Pointwise upper control limits, one per subgroup. Authoritative for rendering when opportunity sizes vary. | |
Vector<double> | Pointwise lower control limits, one per subgroup. May be zero for small opportunity sizes. | |
Vector<double> | Inspection opportunity sizes, one per subgroup, parallel to Values. |
The following code example demonstrates computing a U chart:
// Defect counts and varying inspection opportunity per subgroup
Vector<double> defects = Vector.Create(
new double[] { 4, 6, 3, 8, 5 });
Vector<double> opportunity = Vector.Create(
new double[] { 2.0, 3.0, 1.5, 4.0, 2.5 });
UChart chart = new UChart(defects, opportunity);
chart.Analyze();
Console.WriteLine($"U chart center line: {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}] u={pts[i]:F4} " +
$"UCL={ucls[i]:F4}");Selecting the correct attribute chart
Use the following table as a quick reference:
What you are counting | Sample size | Chart |
|---|---|---|
Defective units (pass/fail per unit) | Variable | P |
Defective units (pass/fail per unit) | Constant | NP |
Defects per unit (multiple nonconformities possible per unit) | Constant opportunity | C |
Defects per unit (multiple nonconformities possible per unit) | Variable opportunity | U |
For a broader decision framework that includes variables and time-weighted charts, see choosing the right analysis. For common mistakes when working with attribute charts, see pitfalls and common mistakes.