Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Quickstart

This tutorial will get you up and running with ProcessBehavior in about 5 minutes.

What You’ll Learn

  1. Chart a plain list of values in two calls

  2. Load data into a ProcessBehavior wrapper

  3. Formulate a study with response, factors, and time

  4. Execute the analysis and create control charts

  5. Detect signals (out-of-control points)

  6. Export results

Setup

First, let’s import the necessary libraries:

The two-call version: a list of values

A column of values with no time column is charted in the order received. The rows are numbered 1..N in an Observation column and the study is a single stream (ADS 2), so the recommended chart is X, with its mR companion:

Recommended chart: X
T=12. Sigma for X/mR rests on 11 moving ranges.
Center 50.167, limits 48.619 to 51.714

If the rows are not in time order, pass the time column with time=. The rest of this tutorial works with a richer dataset: factors, a time order and replicates.

Step 1: Create Sample Data

Let’s create a realistic manufacturing dataset. We’ll simulate a filling machine with:

  • 4 filling lanes (A, B, C, D)

  • Measurements over 10 time periods

  • 3 replicate measurements per lane per time period

Dataset shape: (120, 3)
Loading...

Step 2: Create a ProcessBehavior Wrapper

Wrap your pandas DataFrame in a ProcessBehavior to enable IDE auto-completion and the fluent API:

Available columns:
  - time
  - lane
  - weight

Step 3: Formulate Your Study

Use formulate() to specify:

  • response: The measurement variable

  • factors: Categorical variables that define subgroups

  • time: Time ordering variable

ProcessBehavior automatically detects the Sampling Design State (SDS):

Observed:   ODS 1
Analytical: ADS 1
Recommended chart: Xbar
Valid charts: ['Histogram', 'Xbar', 'S', 'X', 'mR']

Understanding the design-state lineage

The output above reports two design states:

  • ODS (Observed Design State) - what the raw data structure looks like before any cleaning. Computed on the (factor x time) grid as Bishop’s classification of the N_kt distribution.

  • ADS (Analytical Design State) - what survives tidying and drives chart selection, residual availability, and variance decomposition.

For this dataset, both classify as Bishop’s Code 1 (“full replication”): every cell has at least 2 observations. That’s the gold-standard design - it supports the full residual decomposition (R1-R5) and Xbar-S charts.

Other Bishop codes you may see:

CodeCell distributionNotes
1Complete grid, all N_kt >= 2Full residual decomposition
2Complete grid, all N_kt = 1No replication; X/mR only
3Complete grid, mixed N_ktPartial replication
4, 5, 6Incomplete grid (some cells empty)ODS only; collapses to ADS 1/2/3

Step 4: Execute the Analysis

The execute() method computes control chart statistics:

Charts calculated: ['Xbar']
Has residuals: True

View Chart Statistics

Results are returned as plain pandas DataFrames:

Xbar Chart Data:
Loading...

Xbar Statistics:
{'center': np.float64(100.292), 'N': np.int64(3), 'upl': np.float64(103.696), 'lpl': np.float64(96.887)}

Step 5: Visualize with Control Charts

Create interactive Plotly charts with one line:

Loading...

Enhanced Visualization

Add zone shading, signal markers, and statistics:

Loading...

Step 6: Detect Signals

Use Western Electric rules to detect out-of-control conditions:

Signals detected: 1
Has signals: True

Violations:
Loading...

Signal Detection Rules

For Xbar and S charts (categorical comparisons), only Rule 1 applies:

  • Points beyond the control limits

For IMR charts (time series), all 8 Western Electric rules apply:

  • Rule 1: Point beyond 3σ

  • Rule 2: 2 of 3 consecutive in Zone A

  • Rule 3: 4 of 5 consecutive in Zone B or beyond

  • Rule 4: 8+ consecutive same side of center

  • Rule 5: 6+ consecutive trending

  • Rule 6: 14+ consecutive alternating

  • Rule 7: 15+ consecutive in Zone C

  • Rule 8: 8+ consecutive avoiding Zone C

Step 7: Stratified Analysis

For time series analysis by lane, use stratified IMR charts. The by parameter controls how data is grouped:

X chart strata:  ['A', 'B', 'C', 'D']
mR chart strata: ['A', 'B', 'C', 'D']
Loading...

Step 8: Export Results

Export everything to Excel for sharing:

Available as plain DataFrames:
  - result.get_chart('Xbar')
  - result.get_statistics('Xbar')
  - result.residuals  # VAS residuals

Summary

You’ve learned the core ProcessBehavior workflow:

  1. ProcessBehavior(df) - Wrap your data

  2. pb.formulate(...) - Define response, factors, time

  3. study.execute() - Compute statistics

  4. result.plot() - Visualize

  5. result.detect_signals() - Find out-of-control points

Next Steps