# cpistats

> Statistical tools for Continuous Process Improvement (Lean Six Sigma)

[!\[PyPI version](https://img.shields.io/pypi/v/cpistats.svg)](https://pypi.org/project/cpistats/)
[!\[Python versions](https://img.shields.io/pypi/pyversions/cpistats.svg)](https://pypi.org/project/cpistats/)
[!\[License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

\---

## Overview

`cpistats` is a Python package that provides statistically rigorous and reproducible methods commonly used in **Continuous Process Improvement (CPI)** and **Lean Six Sigma** projects.

The library is built around three core principles:

* **Correct statistical implementation** — methods aligned with established references
* **Reproducibility** — deterministic, fully parameterized outputs
* **Validation** — results verified against NIST and Minitab benchmarks

\---

## Installation

```bash
pip install cpistats
```

\---

## Quick Start

```python
from cpistats import two\\\_sample\\\_t\\\_test

data1 = \\\[1.4, 1.3, 1.5, 1.3]
data2 = \\\[1.3, 1.2, 1.4, 1.2]

result = two\\\_sample\\\_t\\\_test(
    data1,
    data2,
    delta0=0.1,
    alternative="greater",
    equal\\\_var=True,
)

print(result.t\\\_statistic)
print(result.p\\\_value)
```

\---

## Implemented Methods

### Hypothesis Tests

|Method|Description|
|-|-|
|`anderson\\\_darling\\\_normality`|Anderson–Darling normality test|
|`one\\\_sample\\\_t\\\_test`|One-sample t-test|
|`two\\\_sample\\\_t\\\_test`|Two-sample t-test (pooled or Welch)|

**Two-sample t-test variants:**

* **Pooled** — assumes equal variances (`equal\\\_var=True`)
* **Welch** — assumes unequal variances (`equal\\\_var=False`)

\---

## Validation

All methods are validated against trusted industry references:

* [**NIST Statistical Reference Datasets (StRD)**](https://www.itl.nist.gov/div898/strd/) — numerical accuracy benchmarks
* **Minitab (v22)** — industry-standard statistical software

### Validation Framework

Each validated dataset includes:

* Input data and parameters
* Reference results from the trusted source
* Computed **Log Relative Error (LRE)** and **Log Absolute Error (LAE)**

Automated validation is run on every change to ensure numerical accuracy and consistency are maintained.

\---

## Project Structure

```
src/cpistats/
├── hypothesis\\\_tests/
│   ├── anderson\\\_darling\\\_normality.py
│   ├── one\\\_sample\\\_t\\\_test.py
│   └── two\\\_sample\\\_t\\\_test.py
├── core/
└── validation/
```

\---

## Design Principles

* **Deterministic outputs** — same inputs always produce the same results
* **Explicit parameter control** — no hidden defaults (e.g., `delta0`, `alternative`, `equal\\\_var`)
* **Industrial alignment** — behavior matches Minitab and other trusted tools
* **Transparent and testable logic** — clean, auditable code

\---

## Roadmap

Planned additions:

* \[ ] Paired t-test
* \[ ] Nonparametric tests (Sign test, Wilcoxon signed-rank test)
* \[ ] Confidence intervals
* \[ ] Effect size metrics (Cohen's d, Hedges' g)
* \[ ] Statistical Process Control (SPC) charts

\---

## License

This project is licensed under the [MIT License](LICENSE).

\---

## Author

**Alexandre Torres**

