Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

control-chart-analyzer

БесплатноБез исполняемых скриптовНе проверен

Statistical process control chart creation and analysis skill with control limit calculation and special cause detection.

a5c-aiот a5c-ai★ 1 947 звёзд на GitHub

Об этом скилле

control-chart-analyzer

You are control-chart-analyzer - a specialized skill for creating and analyzing statistical process control charts with control limit calculation and special cause detection.

Overview

This skill enables AI-powered SPC analysis including:

  • X-bar and R chart generation
  • X-bar and S chart for large subgroups
  • Individual and Moving Range (I-MR) charts
  • p-chart and np-chart for attribute data
  • c-chart and u-chart for defects
  • Control limit calculation (3-sigma)
  • Nelson rules detection
  • Western Electric rules application
  • Out-of-control pattern identification

Prerequisites

  • Python 3.8+ with numpy, scipy, matplotlib
  • Process measurement data
  • Understanding of SPC principles

Capabilities

1. X-bar and R Charts

import numpy as np
from scipy import stats

# Control chart constants
A2 = {2: 1.880, 3: 1.023, 4: 0.729, 5: 0.577, 6: 0.483, 7: 0.419,
      8: 0.373, 9: 0.337, 10: 0.308}
D3 = {2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0.076, 8: 0.136, 9: 0.184, 10: 0.223}
D4 = {2: 3.267, 3: 2.574, 4: 2.282, 5: 2.114, 6: 2.004, 7: 1.924,
      8: 1.864, 9: 1.816, 10: 1.777}

def xbar_r_chart(data, subgroup_size=5):
    """
    Create X-bar and R control chart

    data: 2D array where each row is a subgroup
    """
    n = subgroup_size
    subgroups = np.array(data)

    # Calculate subgroup statistics
    xbars = np.mean(subgroups, axis=1)
    ranges = np.ptp(subgroups, axis=1)  # Range = max - min

    # Grand mean and average range
    xbar_bar = np.mean(xbars)
    r_bar = np.mean(ranges)

    # Control limits for X-bar chart
    xbar_ucl = xbar_bar + A2[n] * r_bar
    xbar_lcl = xbar_bar - A2[n] * r_bar

    # Control limits for R chart
    r_ucl = D4[n] * r_bar
    r_lcl = D3[n] * r_bar

    return {
        "xbar_chart": {
            "center_line": xbar_bar,
            "ucl": xbar_ucl,
            "lcl": xbar_lcl,
            "data": xbars.tolist()
        },
        "r_chart": {
            "center_line": r_bar,
            "ucl": r_ucl,
            "lcl": r_lcl,
            "data": ranges.tolist()
        },
        "subgroup_size": n,
        "num_subgroups": len(subgroups)
    }

2. Individual and Moving Range (I-MR) Chart

def imr_chart(data):
    """
    Create Individual and Moving Range chart
    For individual observations (subgroup size = 1)
    """
    x = np.array(data)
    n = len(x)

    # Moving ranges
    mr = np.abs(np.diff(x))

    # Statistics
    x_bar = np.mean(x)
    mr_bar = np.mean(mr)

    # Control limits (using d2 = 1.128 for n=2)
    d2 = 1.128
    sigma_hat = mr_bar / d2

    x_ucl = x_bar + 3 * sigma_hat
    x_lcl = x_bar - 3 * sigma_hat

    # MR limits (D4 = 3.267 for n=2)
    mr_ucl = 3.267 * mr_bar
    mr_lcl = 0

    return {
        "i_chart": {
            "center_line": x_bar,
            "ucl": x_ucl,
            "lcl": x_lcl,
            "data": x.tolist(),
            "sigma_estimate": sigma_hat
        },
        "mr_chart": {
            "center_line": mr_bar,
            "ucl": mr_ucl,
            "lcl": mr_lcl,
            "data": mr.tolist()
        },
        "num_observations": n
    }

3. Attribute Charts (p-chart, np-chart)

def p_chart(defectives, sample_sizes):
    """
    p-chart for proportion defective
    Variable sample sizes supported
    """
    defectives = np.array(defectives)
    n = np.array(sample_sizes)

    # Proportions
    p = defectives / n

    # Average proportion
    p_bar = np.sum(defectives) / np.sum(n)

    # Control limits (vary with sample size)
    ucl = p_bar + 3 * np.sqrt(p_bar * (1 - p_bar) / n)
    lcl = np.maximum(0, p_bar - 3 * np.sqrt(p_bar * (1 - p_bar) / n))

    return {
        "center_line": p_bar,
        "ucl": ucl.tolist(),  # Variable limits
        "lcl": lcl.tolist(),
        "data": p.tolist(),
        "sample_sizes": n.tolist()
    }

def np_chart(defectives, sample_size):
    """
    np-chart for number defective
    Constant sample size
    """
    defectives = np.array(defectives)
    n = sample_size

    # Average number defective
    np_bar = np.mean(defectives)
    p_bar = np_bar / n

    # Control limits
    ucl = np_bar + 3 * np.sqrt(np_bar * (1 - p_bar))
    lcl = max(0, np_bar - 3 * np.sqrt(np_bar * (1 - p_bar)))

    return {
        "center_line": np_bar,
        "ucl": ucl,
        "lcl": lcl,
        "data": defectives.tolist(),
        "sample_size": n,
        "p_bar": p_bar
    }

4. c-chart and u-chart

def c_chart(defects):
    """
    c-chart for count of defects
    Constant inspection unit size
    """
    c = np.array(defects)

    c_bar = np.mean(c)

    ucl = c_bar + 3 * np.sqrt(c_bar)
    lcl = max(0, c_bar - 3 * np.sqrt(c_bar))

    return {
        "center_line": c_bar,
        "ucl": ucl,
        "lcl": lcl,
        "data": c.tolist()
    }

def u_chart(defects, unit_sizes):
    """
    u-chart for defects per unit
    Variable inspection unit sizes
    """
    defects = np.ar
Полный SKILL.md на GitHub

Установить control-chart-analyzer в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Bash(*)
Read
Write
Edit
Glob
Grep
WebFetch

FAQ

Что делает скилл control-chart-analyzer?

Statistical process control chart creation and analysis skill with control limit calculation and special cause detection.

Как установить скилл control-chart-analyzer?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл control-chart-analyzer запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить control-chart-analyzer с