generate_factorial_design

Generates a complete factorial design based on the input dictionary of variable levels. The function computes all possible combinations of the provided levels for each variable and returns them in a structured data frame.

df = generate_factorial_design(level_dict)

Input Variables

Name Description Type
level_dict A dictionary where keys represent variable names, and values are lists, arrays, or sequences representing the levels of each variable Dictionary

Output Variables

Name Description Type
df A dictionary containing all possible combinations of the levels provided in the input dictionary Dictionary

Example 1

This example demonstrates how to generate a full factorial design for a given set of levels. Consider four variables \(i\),\(j\),\(k\) and \(l\) to assemble full factorial design. The \(i\) variable have a range \([0, 10]\) with 3 levels, the \(j\) variable have a range \([0, 15]\) with 4 levels, The \(k\) variable have a level \([5, 15]\) and the \(l\) variable have a levels \([0, 9, 10, 11, 12]\).

your_problem.ipynb

import numpy as np
from parepy_toolbox import generate_factorial_design

# Input Levels
setup = {
    'i (mm)': np.linspace(0, 10, 3),
    'j (mm)': np.linspace(0, 15, 4),
    'k (mm)': [5, 15],               
    'l (mm)': [0, 9, 10, 11, 12],
}

# Generate Factorial Design
df = generate_factorial_design(setup)

# Print Results
df

Output details:

+----+----------+----------+----------+----------+
|    |   i (mm) |   j (mm) |   k (mm) |   l (mm) |
|----+----------+----------+----------+----------|
|  0 |        0 |        0 |        5 |        0 |
|  1 |        0 |        0 |        5 |        9 |
|  2 |        0 |        0 |        5 |       10 |
|  3 |        0 |        0 |       15 |        0 |
|  4 |        0 |        0 |       15 |        9 |
...
| 69 |       10 |       15 |       15 |        0 |
| 70 |       10 |       15 |       15 |        9 |
| 71 |       10 |       15 |       15 |       10 |
+----+----------+----------+----------+----------+