crashmetrics.sensitivity¶
sensitivity
¶
Sensitivity ranking of design variables.
Which design variables drive an output (HIC, chest deflection, a score)? Three standard measures, all NumPy only:
rank_correlation: Spearman rank correlation of each variable with the output. Works with any sample (DOE, test series, random runs); catches monotonic effects.partial_rank_correlation: partial rank correlation (PRCC): the rank correlation after removing the (rank-linear) effect of the other variables, so a strong variable does not hide a weaker one. Used for the ranking.regression_coefficients: standardised regression coefficients (SRC) of a linear fit, and its R². Shows the share of each variable when the response is close to linear (R² near 1).morris_effects: Morris elementary effects (mu*, sigma) from acrashmetrics.doe.morris_design: a cheap screening that also flags non-linear or interacting variables (large sigma).
rank_sensitivity runs the first three on a table of runs and returns
the variables ranked by importance.
SensitivityRanking
dataclass
¶
MorrisEffect
dataclass
¶
Morris elementary effects of one variable (in output units per unit-cube step: comparable between variables).
rank_correlation
¶
Spearman rank correlation (-1..1) of each input with the output.
Runs with a missing (NaN) input or output are left out. A constant input gets 0.
partial_rank_correlation
¶
Partial rank correlation coefficient (PRCC, -1..1) of each input.
Inputs and output are rank-transformed; for each input, the ranks of that input and of the output are regressed on the ranks of the other inputs, and the residuals are correlated.
regression_coefficients
¶
regression_coefficients(
inputs: Mapping[str, ArrayLike], output: ArrayLike
) -> tuple[dict[str, float], float]
Standardised regression coefficients and R² of a linear fit.
SRC_i = b_i sd(x_i) / sd(y). With independent inputs, SRC_i² is the share of the output variance explained by input i (they sum to R²).
rank_sensitivity
¶
rank_sensitivity(
rows: Sequence[Mapping[str, object]],
inputs: Sequence[str],
output: str,
) -> SensitivityRanking
Rank design variables for one output from a table of runs.
rows are dicts such as crashmetrics.features.feature_table
output or crashmetrics.doe.Design.rows joined with results; rows
without a numeric output (failed runs) are left out.
morris_effects
¶
morris_effects(
design: Design, output: ArrayLike
) -> list[MorrisEffect]
Elementary effects from a crashmetrics.doe.morris_design.
output has one value per run of the design, in run order.
Returns the variables sorted by mu_star (largest first).