Statistical Process Control Charts
Project description
pyshewhart - Statistical Process Control Charts
Statistical process control charts (also known as "Shewhart charts" after Walter A. Shewhart) are widely used in manufacturing and industry as a quality-control tool.
The aim of this project is to provide an easy-to-use Python module for generating the following types of control charts:
- X̅ and R
- X̅ and S
- Cumulative Sum (CUSUM)
- P-attribute
In addition to checking the data against the standard 3σ control limits, it can also be evaluated against the well-known "Western Electric rule set" to detect additional statistical anomalies:
Usage
As a Python library:
An X̅ and R (mean and range) chart can be generated as simply as:
import random
import pyshewhart
measurements = [random.random() for _ in range(200)]
pyshewhart.XbarR(measurements)
If you have time information, you can also provide that. Supported time types include:
datetimetimedelta- various string formats (as supported by
dateutil.parser.parse) - Unix timestamps
- elapsed seconds (
intorfloat)
seconds = range(200)
pyshewhart.XbarR(seconds, measurements)
Notice that now the plot shows both sample numbers and elapsed seconds.
Console Script:
Given a CSV file field_strengths_nT.csv containing timeseries and measurement data:
2022-10-12, 59194.401
2022-10-13, 59176.972
2022-10-14, 59179.485
2022-10-15, 59189.235
...
...
2023-10-08, 59196.725
2023-10-09, 59194.435
2023-10-10, 59187.456
2023-10-11, 59196.135
we can generate an X̅ and S (mean and standard deviation) plot with the following shell command:
$ pyshewhart field_strengths_nT.csv xbar-s 7 --units "nT" --title "Field Strength"
Examples
A few other examples can be found in the examples/ directory.
Several of these are recreated from a well-known textbook titled Managing Quality: Integrating the Supply Chain by S. Thomas Foster, including this X̅ and R chart:
Also a P-attribute chart:
The following shows the capabilities of a CUSUM chart to detect small amounts of drift.
First we see normal data:
And here we see the chart detecting a small amount of simulated drift:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pyshewhart-1.0.1.tar.gz.
File metadata
- Download URL: pyshewhart-1.0.1.tar.gz
- Upload date:
- Size: 21.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef13015087558842cd0588cc8abbf9f777d08e9cdff896bd25f73075fd7c5ff0
|
|
| MD5 |
47ddc05e5c34254c9059f230f46688e2
|
|
| BLAKE2b-256 |
e162ddc639a3ba27dc0ef3c48c95267eced9f4365b0be7f3397d164bb56c9c0b
|