mixle.doe.analysis module¶
Analysis of designed experiments: factorial effects and second-order response surfaces.
These turn the runs of a design (see mixle.doe.factorial) and their measured responses into the
quantities a practitioner reads off: the effect of each factor and interaction in a two-level
design, and – for a response-surface design – the fitted second-order model, its stationary point,
and the canonical (eigenvalue) analysis that says whether that point is a maximum, minimum, or saddle.
- class FactorialEffects(terms, coef, effects, intercept, residual_std)[source]
Bases:
objectEstimated effects from a two-level factorial / fractional-factorial / Plackett-Burman design.
- Parameters:
- coef
least-squares regression coefficients in coded
+/-1units.- Type:
- effects
the classical effect per term – the change in mean response as a factor moves from its low to its high level, i.e.
2 * coef(the intercept entry is just the grand mean).- Type:
- intercept
the grand mean of the response.
- Type:
- residual_std
residual standard deviation when the design has spare runs (else
None).- Type:
float | None
- coef: ndarray
- effects: ndarray
- intercept: float
- factorial_effects(design, y, *, interactions=True, coded=False)[source]
Estimate main effects and two-factor interactions from a two-level design.
Fits the linear model
y ~ 1 + x_i (+ x_i x_j)in coded+/-1units by least squares; the coefficients are half the classical effects.designis the(n, d)run matrix (the real factor levels, coded to+/-1automatically – or passcoded=Trueif it is already+/-1),ythe measured responses. Setinteractions=Falsefor a main-effects-only (e.g. screening) fit.
- class ResponseSurface(coef, terms, b, B, stationary_point, eigenvalues, kind, residual_std)[source]
Bases:
objectA fitted second-order response surface
y = b0 + b'x + x'Bxand its canonical analysis.- Parameters:
- coef
full coefficient vector (intercept, linears, then the upper-triangular second-order terms).
- Type:
- b
linear coefficient vector
(d,).- Type:
- B
symmetric
(d, d)matrix of quadratic coefficients (cross terms split onto both halves).- Type:
- stationary_point
x*solvinggrad = b + 2 B x = 0(least-squares ifBis singular).- Type:
- eigenvalues
eigenvalues of
B– all negative => the stationary point is a maximum, all positive => a minimum, mixed signs => a saddle (a ridge if some are ~0).- Type:
- kind
"maximum"/"minimum"/"saddle".- Type:
- residual_std
residual standard deviation when the design has spare runs (else
None).- Type:
float | None
- coef: ndarray
- b: ndarray
- B: ndarray
- stationary_point: ndarray
- eigenvalues: ndarray
- kind: str
- predict(x)[source]
Predict the response at points
x(m, d)from the fitted surface.- Return type:
- response_surface(x, y)[source]
Fit a full second-order (quadratic) response surface and analyse its stationary point.
Least-squares-fits
y = b0 + sum b_i x_i + sum_{i<=j} b_{ij} x_i x_jto the design runsx(n, d)and responsesy, then solves for the stationary pointx* = -1/2 B^{-1} band classifies it from the eigenvalues of the quadratic matrixB. Fit on the coded design for a well-conditioned model (the classic central-composite / Box-Behnken workflow).- Return type:
ResponseSurface
- design_diagnostics(design, model, *, ref=None)[source]
Quality diagnostics for a design under a model – “is this a good design to run?”.
Builds the model matrix
F = model(design)and reports, relative to a hypothetical perfectly orthogonal design (where each is1.0):d_efficiency–det(M)**(1/p) / n: overall coefficient-estimation precision;a_efficiency–p / (n * trace(M^-1)): average coefficient variance;g_efficiency–p / (n * max prediction variance)overref(or the design itself);condition_numberofM(large => near-collinear / fragile to fit);max_correlation– the largest absolute pairwise correlation among the non-intercept model columns (the aliasing check;0for an orthogonal design).
modelis a model-matrix function such asmixle.doe.optimal.polynomial_features(). Use it on the coded design for meaningful efficiencies.- Return type: