PyDOE: An Experimental Design Package for Python
PyDOE is a Python package for design of experiments (DOE), enabling scientists, engineers, and statisticians to efficiently construct experimental designs. It provides extensive support for various DOE methods, including factorial, response-surface, and space-filling designs. The project is actively maintained, with a focus on integrating features from its community forks into the main package.
Warnings
- breaking Older versions of `pydoe` (prior to 0.9.x) were not compatible with Python 3 directly, primarily due to changes in the division operator. Attempts to use them with Python 3.x often resulted in `SyntaxError` or `TypeError`. The current version (>=0.9.x) explicitly requires Python >=3.10.
- gotcha Historically, several forks like `pyDOE2` and `pyDOE3` emerged due to perceived inactivity or unaddressed bugs in the original `pydoe`. While these forks offered updates and new features, the official `pydoe` project is now actively maintained and aims to integrate these improvements.
- gotcha In `pydoe` versions before 0.9.x, users might have encountered `DEPRECATION: pyDOE is being installed using the legacy 'setup.py install'` warnings due to the absence of a `pyproject.toml` file.
- gotcha Some functions, like `ccdesign`, in older `pydoe` versions were reported to have issues with specific `numpy` versions, leading to `TypeError: can't multiply sequence by non-int of type 'numpy.float64'`.
Install
-
pip install pydoe
Imports
- ff2n
from pydoe import ff2n
- lhs
from pydoe import lhs
- ccdesign
from pydoe import ccdesign
Quickstart
import numpy as np
from pydoe import ff2n
# Create a 2^3 full-factorial design (3 factors, each at 2 levels)
design = ff2n(3)
print("2^3 Full-Factorial Design Matrix:")
print(design)
# Example of Latin Hypercube Sampling (LHS) for 2 variables, 5 samples
from pydoe import lhs
lhs_samples = lhs(2, samples=5)
print("\nLatin Hypercube Samples (2 variables, 5 samples):")
print(lhs_samples)