Tech News
← Back to articles

Statistical Process Control in Python

read original related products more articles

In this workshop, we will learn how to perform statistical process control in Python, using statistical tools and plotnine visualizations! Statistical Process Control refers to using statistics to (1) measure variation in product quality over time and (2) identify benchmarks to know when intervention is needed. Let’s get started!

Getting Started

Packages # Remember to install these packages using a terminal, if you haven't already! ! pip install pandas plotnine scipy pip install pandas plotnine scipy We’ll be using pandas for data manipulation, plotnine for visualization, and scipy for statistical functions. import pandas as pd pandaspd from plotnine import * plotnine

Custom Functions This workshop uses custom functions from the functions/ directory. You may need both: - functions_distributions.py - for reliability and distribution functions - functions_process_control.py - for statistical process control functions To use these functions, you need to acquire them from the repository at github.com/timothyfraser/sigma/tree/main/functions. Add the functions directory to your Python path import sys sys import os os # Add the functions directory to Python path 'functions' ) # or path to wherever you placed the functions folder sys.path.append( Once you have the functions available, you can import them: from functions_distributions import density, tidy_density, approxfun functions_distributionsdensity, tidy_density, approxfun # from functions_process_control import ggprocess, ggsubgroup, ggmoving, ggcapability # if needed

Our Case For today’s workshop, we’re going to think about why quality control matters in a local economy, by examining the case of the Japanese Hot Springs bath economy! Hot springs, or onsen, are a major source of tourism and recreation for families in Japan, bringing residents from across the country every year to often rural communities where the right geological conditions have brought on naturally occurring hot springs. Restaurants, taxi and bus companies, and many service sector firms rely on their local onsen to bring in a steady stream (pun intended) of tourists to the local economy. So, it’s often in the best interest of onsen operators to keep an eye on the temperature, minerals, or other aspects of their hot springs baths to ensure quality control, to keep up their firm (and town’s!) reputation for quality rest and relaxation! Onsen-goers often seek out specific types of hot springs, so it’s important for an onsen to actually provide what it advertises! Serbulea and Payyappallimana (2012) describe some of these benchmarks. Temperature : Onsen are divided into “Extra Hot Springs” ( >42°C ), “Hot Springs” ( 41~34°C ), and “Warm Springs” ( 33~25°C ).

pH : Onsen are classified into “Acidic” ( pH < 3 ), “Mildly Acidic” ( pH 3~6 ), “Neutral” ( pH 6~7.5 ), “Mildly alkaline” ( pH 7.5~8.5 ), and “Alkaline” ( pH > 8.5 ).

Sulfur: Sulfur onsen typically have about 2mg of sulfur per 1kg of hot spring water; sulfur levels must exceed 1 mg to count as a Sulfur onsen. (It smells like rotten eggs!) These are decent examples of quality control metrics that onsen operators might want to keep tabs on!