mixle.doe.optimal module¶
Optimal experimental design via information-matrix criteria (WS-E).
For a regression model with basis (model matrix) F = model(X), the information matrix is
M = F.T @ F – the Gaussian-noise Fisher information for the linear coefficients, up to the
noise variance. An “alphabetic” optimal design picks the n design points that optimize a scalar
functional of M:
D-optimal – maximize
log det M(shrink the joint confidence ellipsoid of the coefficients)A-optimal – minimize
trace(M^{-1})(shrink the average coefficient variance)I-optimal – minimize the mean prediction variance over a reference set
Criteria are looked up through a registry (register_criterion / criterion= name) following the
“register, don’t branch” pattern; each returns a merit that is maximized. optimal_design()
selects points from a candidate pool (a Sobol design over the bounds, or a user-supplied array) by a
modified Fedorov exchange: from a random starting subset, repeatedly apply the single in-design /
candidate swap that most improves the criterion until no swap helps, across a few random restarts.
- class Criterion(*args, **kwargs)[source]
Bases:
ProtocolThe optimality-criterion contract registered via
register_criterion(D/A/I-optimality).A criterion maps the information matrix
M = F.T @ Fto a scalar merit thatmixle.doe.optimal.optimal_design()maximizes over candidate designs. It is called asfn(info, *, ref)whererefis an optional reference model matrix (used by I-optimality). Built-insmixle.doe.optimal.d_criterion(),a_criterion(), andi_criterion()satisfy this contract.
- polynomial_features(degree=1, *, bias=True)[source]
Return a model-matrix function building polynomial features up to
degree(with interactions).The returned
f(X)maps an(n, d)point array to an(n, p)model matrix: an optional intercept column, then every monomialprod(x_j)over index multisets of size1..degree(sodegree=1is linear,degree=2is a full quadratic response surface including the cross termsx_i x_j).
- d_criterion(info, *, ref=None)[source]
D-optimality merit:
log det M(-infifMis singular). Higher is better.
- a_criterion(info, *, ref=None)[source]
A-optimality merit:
-trace(M^{-1})(-infif singular). Higher is better.
- i_criterion(info, *, ref=None)[source]
I-optimality merit:
-meanprediction variance overref(-infif singular).The prediction variance at a reference row
gisg M^{-1} g; this returns the negative mean over the reference model matrixrefso larger is better. Falls back to A-optimality when no reference set is supplied.
- register_criterion(name, fn, aliases=())[source]
Register an optimality criterion
fnundername(and anyaliases).fnis called asfn(info, *, ref)with the information matrixM = F.T @ Fand must return a merit thatoptimal_design()maximizes. This is the extension point for new criteria – registering is all that is needed, no edits to the exchange loop.
- available_criteria()[source]
Return the sorted names (and aliases) of all registered optimality criteria.
- optimal_design(bounds, n, *, candidates=None, model=None, criterion='D', n_candidates=256, n_restarts=5, max_iter=100, ref=None, seed=None)[source]
Return an
n-point optimal design selected from a candidate pool by Fedorov exchange.The pool is either generated as a Sobol design of
n_candidatespoints over per-dimensionbounds, or supplied directly as an(P, d)candidatesarray (in which caseboundsmay beNone).modelis a model-matrix function (defaultpolynomial_features()degree 1, i.e. linear with intercept);criterionselects the optimality merit ("D"/"A"/"I"or any registered name / callable). The best design overn_restartsrandom starts is returned as an(n, d)array. For"I"optimality, prediction variance is averaged overref(a model matrix) when given, else over the candidate pool.Raises if
nis below the number of model parameters (the information matrix would be singular).