Getting Started

This page gives you a working result from the Numerics.NET SPC API as quickly as possible and introduces the core mental model for using the library.

The calculation-first approach

The Numerics.NET SPC API computes statistical results and returns them as immutable objects. It does not draw charts, update dashboards, or maintain state across calls. You supply the data; the library computes the numbers; your application layer renders and responds.

This model makes the library composable with any UI framework, reporting library, web API, or batch pipeline.

The standard SPC lifecycle

A typical SPC analysis in this library follows six steps:

  1. Choose an analysis. Select the chart family that matches your data type and measurement structure. See choosing the right analysis.

  2. Prepare the data. Order observations chronologically and arrange subgroups correctly. See data contracts and preparation.

  3. Construct and analyze a chart. Create a chart object such as IndividualsMovingRangeChartSet and call its Analyze() method.

  4. Interpret stability. Examine rule violations to determine whether the process is in statistical control.

  5. Compute capability if appropriate. Capability analysis is meaningful only on stable processes.

  6. Integrate or persist results. Serialize the result, render it in a UI, or return it from a service. See integration and persistence.

Quick start

The chart-centered API uses a construct-analyze-inspect-deploy lifecycle. Create a chart such as IndividualsMovingRangeChartSet, call Analyze() to fit the control limits, then inspect the results and optionally call Deploy() to create a reusable baseline for Phase II monitoring.

The following example performs a complete Individuals–Moving Range (I‑MR) analysis, evaluates Nelson rules, and computes capability against two-sided specification limits:

C#
// Individual measurements in chronological order
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
};
Vector<double> observations = Vector.Create(data);

// Construct and analyze an Individuals (I-MR) chart
IndividualsMovingRangeChartSet chart =
    new IndividualsMovingRangeChartSet(observations);
chart.Analyze();

Console.WriteLine(
    $"Individuals chart CL  = {chart.IndividualsSeries.CenterLine:F4}");
Console.WriteLine(
    $"Individuals chart UCL = {chart.IndividualsSeries.UpperControlLimit:F4}");
Console.WriteLine(
    $"Individuals chart LCL = {chart.IndividualsSeries.LowerControlLimit:F4}");

// Evaluate Nelson rules
RuleSetEvaluation ruleResult =
    chart.IndividualsSeries.EvaluateRules(ControlRuleSets.Nelson);
if (ruleResult.HasViolations)
    Console.WriteLine($"Rule violations: {ruleResult.Violations.Count}");
else
    Console.WriteLine("No rule violations detected.");

// Capability analysis with spec limits
var specs = new SpecificationLimits(Lower: 9.0, Upper: 13.0);
CapabilityAnalysisResult cap = Capability.Analyze(observations, specs);
Console.WriteLine($"Cpk = {cap.Cpk:F4}");

The fitted chart exposes chart data, rule violations, capability metrics, and diagnostics. The next section shows how to inspect each part.

Inspecting results

After calling Analyze(), the ControlChart exposes four main areas:

  • Chart series properties (such as IndividualsSeries, MovingRangesSeries) — the chart-set data (values, limits, center line).

  • EvaluateRules on each chart series — rule evaluation result with violations, or null if no rule set was supplied.

  • Capability — capability and performance metrics, or null if no specification limits were supplied.

  • Diagnose() — a list of advisory messages generated during the analysis.

The following snippet shows how to access a chart value, examine a rule violation, and read a capability metric:

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
};
Vector<double> observations = Vector.Create(data);

IndividualsMovingRangeChartSet chart =
    new IndividualsMovingRangeChartSet(observations);
chart.Analyze();

// Access the individuals series
FixedLimitSeries iSeries = chart.IndividualsSeries;
Console.WriteLine(
    $"Point[0] = {iSeries.Values[0]:F4}  (CL={iSeries.CenterLine:F4})");

// Inspect rule violations
RuleSetEvaluation ruleResult =
    chart.IndividualsSeries.EvaluateRules(ControlRuleSets.Nelson);
foreach (RuleViolation v in ruleResult.Violations)
{
    Console.WriteLine(
        $"[{v.RuleId}] trigger index={v.TriggerIndex}, " +
        $"window [{v.WindowStart}..{v.WindowStart + v.WindowLength - 1}]");
}

// Capability metrics
var specs = new SpecificationLimits(Lower: 9.0, Upper: 13.0);
CapabilityAnalysisResult cap = Capability.Analyze(observations, specs);
Console.WriteLine($"Cp={cap.Cp:F4}  Cpk={cap.Cpk:F4}");
Console.WriteLine($"Pp={cap.Pp:F4}  Ppk={cap.Ppk:F4}");

// Diagnostics from Diagnose()
DiagnosticReport report = chart.Diagnose();
foreach (DiagnosticMessage msg in report.Messages)
    Console.WriteLine($"[{msg.Severity}] {msg.Message}");

Key concepts at a glance

Before reading further, it is useful to be clear about these terms:

Control limits vs specification limits

Control limits are computed from the process data and describe natural process variation. Specification limits are customer or engineering requirements. They are unrelated; using one in place of the other is a common and serious error.

Defect vs defective

A defective is a unit that fails inspection (use P or NP charts). A defect is an individual nonconformity within a unit; a unit may have multiple defects (use C or U charts). Using the wrong chart family gives statistically incorrect results.

Capability vs performance

Capability (Cp, Cpk) uses within-process sigma. Performance (Pp, Ppk) uses overall sigma. Capability estimates what the process could achieve if only common causes were present. Performance describes what the process actually delivered over the sampled period.

Stable (in control) vs unstable (out of control)

A stable process exhibits only common-cause variation. An unstable process shows special-cause signals. Capability analysis on an unstable process produces misleading results. Always assess stability before computing capability.

Where to go next

See Also