mqr.doe.

Design#

class mqr.doe.Design(names: list[str], levels: DataFrame, runs: Index, pttypes: Series, blocks: DataFrame)#

An experimental design.

Designs should normally be constructed using the from_* methods, which wrap calls to the pyDOE3 library. Designs can also be constructed manually, either from pyDOE3 or any other method, including directly from numpy arrays. See Design of Experiments.

Designs are composable by concatenation with the + operator.

Attributes:
nameslist[str]

Names of variables.

levelsnp.ndarray

Two-dimensional array containing the levels for each experiment, with a column for each variables and a row for each run.

runsnp.ndarray

Numerical labels for each run. Useful for tracking runs after randomisation.

pttypesarray_like

Numerical label for each point type: | 0 : centre point | 1 : corner point | 2 : axial point

Methods

as_block(level[, name])

Return the same set of runs with a block label set to level.

from_axial(names[, exclude, magnitude])

Construct a design from runs of axial points.

from_ccdesign(names[, center, alpha, face])

Construct a design from pyDOE3.ccdesign(...).

from_centrepoints(names, n)

Construct a design from runs of centrepoints.

from_fracfact(names, gen)

Construct a design from pyDOE3.fracfact(...).

from_fullfact(names, levels[, scale_origin, ...])

Construct a design from pyDOE3.fullfact(...).

from_levels(names, levels[, runs])

Construct a design from an array of levels.

get_factor_df(name[, ref_levels])

Create a dataframe containing all unique levels in this design for a variable, and a reference level for all others.

randomise_runs(*order)

Return the same set of runs, randomised over their run labels.

replicate(n[, label])

Create a new design with each run replicated n times.

to_df()

Construct a dataframe representation of the design.

transform(**transforms)

Apply transforms to the levels of this design.

Examples

>>> Design.from_full_fact(['x1', 'x2', 'x3'], [2, 2, 2])
   PtType    x1   x2   x3
1       1  -1.0 -1.0 -1.0
2       1   1.0 -1.0 -1.0
3       1  -1.0  1.0 -1.0
4       1   1.0  1.0 -1.0
5       1  -1.0 -1.0  1.0
6       1   1.0 -1.0  1.0
7       1  -1.0  1.0  1.0
8       1   1.0  1.0  1.0
>>> d1 = Design.from_fracfact(['x1', 'x2', 'x3', 'x4'], 'a b c abc')
>>> d2 = Design.from_centrepoints(['x1', 'x2', 'x3', 'x4'], 3)
>>> d1.as_block(1) + d2.as_block(2)
    PtType  Block   x1   x2   x3   x4
1        1      1 -1.0 -1.0 -1.0 -1.0
2        1      1  1.0 -1.0 -1.0  1.0
3        1      1 -1.0  1.0 -1.0  1.0
4        1      1  1.0  1.0 -1.0 -1.0
5        1      1 -1.0 -1.0  1.0  1.0
6        1      1  1.0 -1.0  1.0 -1.0
7        1      1 -1.0  1.0  1.0 -1.0
8        1      1  1.0  1.0  1.0  1.0
9        0      2  0.0  0.0  0.0  0.0
10       0      2  0.0  0.0  0.0  0.0
11       0      2  0.0  0.0  0.0  0.0