CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-pydoe3

Design of experiments library for Python with comprehensive experimental design capabilities

Pending
Overview
Eval results
Files

taguchi-robust.mddocs/

Taguchi & Robust Design

Taguchi methodology for robust parameter design with orthogonal arrays and signal-to-noise ratio analysis. These methods focus on minimizing variability and improving product/process robustness by identifying factor settings that are insensitive to noise and environmental conditions.

Capabilities

Taguchi Design Generation

Create experimental designs using Taguchi orthogonal arrays with actual factor levels.

def taguchi_design(oa_name: ORTHOGONAL_ARRAY_NAMES, levels_per_factor: List[List]) -> np.ndarray:
    """
    Generate a Taguchi design matrix using an orthogonal array and factor levels
    
    Parameters:
    - oa_name: str, name of Taguchi orthogonal array (e.g., 'L4(2^3)', 'L8(2^7)')
    - levels_per_factor: list of lists, actual factor settings for each factor
                        Length must match number of columns in orthogonal array
    
    Returns:
    - design_matrix: 2d-array, design matrix with actual factor settings
    """

Usage Example:

import pyDOE3

# Define factor levels for L9(3^4) array (4 factors, 3 levels each)
factor_levels = [
    [100, 150, 200],      # Temperature (°C)
    [10, 20, 30],         # Pressure (bar) 
    [0.5, 1.0, 1.5],      # Flow rate (L/min)
    ['A', 'B', 'C']       # Catalyst type
]

# Generate Taguchi design
design = pyDOE3.taguchi_design("L9(3^4)", factor_levels)
print(f"Design shape: {design.shape}")  # (9, 4)
print("Factor combinations:")
print(design)

Orthogonal Array Management

Access and explore available Taguchi orthogonal arrays.

def list_orthogonal_arrays() -> List[str]:
    """
    List descriptive names of available Taguchi orthogonal arrays
    
    Returns:
    - array_names: list of str, available array names like ['L4(2^3)', 'L8(2^7)', ...]
    """
def get_orthogonal_array(oa_name: ORTHOGONAL_ARRAY_NAMES) -> np.ndarray:
    """
    Return a Taguchi orthogonal array by its descriptive name
    
    Parameters:
    - oa_name: str, name of the array (e.g., 'L4(2^3)', 'L8(2^7)', 'L9(3^4)')
    
    Returns:
    - array: 2d-array, orthogonal array with zero-indexed factor levels
    """

Usage Examples:

import pyDOE3

# List all available orthogonal arrays
arrays = pyDOE3.list_orthogonal_arrays()
print("Available arrays:", arrays)

# Get specific orthogonal array
l4_array = pyDOE3.get_orthogonal_array("L4(2^3)")
print(f"L4 array shape: {l4_array.shape}")  # (4, 3)
print("L4 array:")
print(l4_array)

# Get larger array for more factors
l16_array = pyDOE3.get_orthogonal_array("L16(2^15)")
print(f"L16 array shape: {l16_array.shape}")  # (16, 15)

Signal-to-Noise Ratio Analysis

Calculate signal-to-noise ratios for Taguchi robust design analysis.

class TaguchiObjective(Enum):
    """
    Enumeration for Taguchi optimization objectives
    """
    LARGER_IS_BETTER = "larger is better"
    SMALLER_IS_BETTER = "smaller is better" 
    NOMINAL_IS_BEST = "nominal is best"
def compute_snr(responses: np.ndarray, objective: TaguchiObjective = TaguchiObjective.LARGER_IS_BETTER) -> float:
    """
    Calculate the Signal-to-Noise Ratio (SNR) for Taguchi designs
    
    Parameters:
    - responses: array-like, response measurements for SNR calculation
    - objective: TaguchiObjective, optimization objective type
    
    Returns:
    - snr: float, signal-to-noise ratio in decibels (dB)
    """

SNR Formulas:

  • Larger is Better: SNR = -10 × log₁₀(mean(1/y²))
  • Smaller is Better: SNR = -10 × log₁₀(mean(y²))
  • Nominal is Best: SNR = 10 × log₁₀(mean²/variance)

Usage Examples:

import pyDOE3
import numpy as np

# Strength measurements (larger is better)
strength_data = np.array([45.2, 47.8, 44.1, 46.9, 48.3])
snr_strength = pyDOE3.compute_snr(strength_data, pyDOE3.TaguchiObjective.LARGER_IS_BETTER)
print(f"Strength SNR: {snr_strength:.2f} dB")

# Defect rate (smaller is better)
defect_data = np.array([0.02, 0.015, 0.018, 0.022, 0.016])
snr_defects = pyDOE3.compute_snr(defect_data, pyDOE3.TaguchiObjective.SMALLER_IS_BETTER)
print(f"Defect SNR: {snr_defects:.2f} dB")

# Dimension accuracy (nominal is best, target = 50.0)
dimension_data = np.array([49.8, 50.2, 49.9, 50.1, 50.0])
snr_dimension = pyDOE3.compute_snr(dimension_data, pyDOE3.TaguchiObjective.NOMINAL_IS_BEST)
print(f"Dimension SNR: {snr_dimension:.2f} dB")

Available Orthogonal Arrays

pyDOE3 provides 17 standard Taguchi orthogonal arrays:

Two-Level Arrays (2^n)

  • L4(2^3): 4 runs, up to 3 factors, 2 levels each
  • L8(2^7): 8 runs, up to 7 factors, 2 levels each
  • L12(2^11): 12 runs, up to 11 factors, 2 levels each
  • L16(2^15): 16 runs, up to 15 factors, 2 levels each
  • L32(2^31): 32 runs, up to 31 factors, 2 levels each
  • L64(2^31): 64 runs, up to 31 factors, 2 levels each

Three-Level Arrays (3^n)

  • L9(3^4): 9 runs, up to 4 factors, 3 levels each
  • L27(3^13): 27 runs, up to 13 factors, 3 levels each
  • L81(3^40): 81 runs, up to 40 factors, 3 levels each

Four-Level Arrays (4^n)

  • L16(4^5): 16 runs, up to 5 factors, 4 levels each
  • L64(4^21): 64 runs, up to 21 factors, 4 levels each

Five-Level Arrays (5^n)

  • L25(5^6): 25 runs, up to 6 factors, 5 levels each

Mixed-Level Arrays

  • L18(6^1 3^6): 18 runs, 1 factor with 6 levels + 6 factors with 3 levels
  • L36(3^23): 36 runs, up to 23 factors, 3 levels each
  • L50(2^1 5^11): 50 runs, 1 factor with 2 levels + 11 factors with 5 levels
  • L54(2^1 3^25): 54 runs, 1 factor with 2 levels + 25 factors with 3 levels
  • L32(2^1 4^9): 32 runs, 1 factor with 2 levels + 9 factors with 4 levels

Taguchi Methodology Workflow

1. Parameter Design Process

# Step 1: Select orthogonal array based on factors and levels
available_arrays = pyDOE3.list_orthogonal_arrays()

# Step 2: Define factor levels
control_factors = [
    [20, 25, 30],     # Temperature
    [1, 2, 3],        # Speed  
    [0.1, 0.2, 0.3],  # Feed rate
    ['A', 'B', 'C']   # Tool type
]

# Step 3: Generate experimental design
design = pyDOE3.taguchi_design("L9(3^4)", control_factors)

# Step 4: Run experiments and collect responses
# responses = run_experiments(design)

# Step 5: Calculate SNR for each run
# snr_values = [pyDOE3.compute_snr(response, objective) for response in responses]

2. Factor Effect Analysis

After collecting experimental data:

  1. Calculate SNR for each experimental run
  2. Compute average SNR for each factor level
  3. Identify optimal factor settings (highest SNR)
  4. Perform confirmation experiments

3. Design Selection Guidelines

Array Selection Rules:

  • Choose array with sufficient factors and levels
  • Minimize number of experiments while maintaining orthogonality
  • Consider mixed-level arrays for different factor types

Factor Assignment:

  • Assign most important factors to columns with highest priority
  • Use interaction columns if interactions are expected
  • Reserve some columns for potential interactions

Types

from typing import List, Literal
from enum import Enum
import numpy as np

# Orthogonal array names type
ORTHOGONAL_ARRAY_NAMES = Literal[
    "L4(2^3)", "L8(2^7)", "L9(3^4)", "L12(2^11)", "L16(2^15)", "L16(4^5)",
    "L18(6^1 3^6)", "L25(5^6)", "L27(2^1 3^12)", "L32(2^31)", "L32(2^1 4^9)",
    "L36(3^23)", "L50(2^1 5^11)", "L54(2^1 3^25)", "L64(2^31)", "L64(4^21)", "L81(3^40)"
]

# Factor levels specification
FactorLevels = List[List]

# Design matrix type  
Taguchi_Matrix = np.ndarray

class TaguchiObjective(Enum):
    LARGER_IS_BETTER = "larger is better"
    SMALLER_IS_BETTER = "smaller is better" 
    NOMINAL_IS_BEST = "nominal is best"

Integration with Other Design Methods

Taguchi designs complement other experimental approaches:

  • Screening Phase: Use Taguchi arrays for initial factor screening
  • Response Surface: Follow up with RSM for optimization
  • Robust Design: Combine with noise factors for comprehensive robustness
  • Sequential Experiments: Use confirmation runs to validate optimal settings

Install with Tessl CLI

npx tessl i tessl/pypi-pydoe3

docs

classical-factorial.md

index.md

optimal-design.md

response-surface.md

sampling-randomized.md

taguchi-robust.md

utilities-advanced.md

tile.json