pyvale.validation.validprof module¶
Epistemic bounds comparisons, metric reductions and nuisance profiling.
- find_metric_epis_extrema(valid_result, observable, metric, *, reduce_axes=(EValidResAxis.SIM_TRANS, EValidResAxis.SIM_NUIS, EValidResAxis.EXP_TRANS, EValidResAxis.EXP_NUIS), selectors=None)[source]¶
Reduce stored metric outputs without recalculating comparisons.
Physical and unselected offset axes remain. Joint minima/maxima are taken over the requested axes, not a mixed minimax operation. Singleton omitted epistemic axes need no special handling. All-missing cells retain NaN/-1.
- Parameters:
valid_result (
ValidResult) – Calculated metric fields and observable metadata.observable (
str) – Observable tag identifying matching metadata and observations.metric (
EMetricType) – Metric to select or evaluate.reduce_axes (
tuple[EValidResAxis,], optional) – Epistemic or offset result axes to collapse, in addition to any fixed selections.selectors (
dict[EValidResAxis,int]orNone, optional) – Zero-based indices keyed by result axis; omitted axes follow the operation’s defaults.
- Returns:
ValidMetricExtrema– Pointwise extrema over the reduced axes, with origin indices appended as a final dimension to each retained result grid.
- profile_epis_nuisance_extrema(valid_result, observable, metric, *, selectors=None)[source]¶
Profile both nuisance axes, retaining transferable and physical axes.
- Parameters:
valid_result (
ValidResult) – Calculated metric fields and observable metadata.observable (
str) – Observable tag identifying matching metadata and observations.metric (
EMetricType) – Metric to select or evaluate.selectors (
dict[EValidResAxis,int]orNone, optional) – Zero-based indices keyed by result axis; omitted axes follow the operation’s defaults.
- Returns:
ValidMetricExtrema– Metric extrema over simulation and experiment nuisance dimensions, with original nuisance indices.
- find_metric_epis_supports(valid_case, valid_result, observable, metric, *, reduce_axes=(EValidResAxis.SIM_TRANS, EValidResAxis.SIM_NUIS, EValidResAxis.EXP_TRANS, EValidResAxis.EXP_NUIS), selectors=None)[source]¶
Envelope original simulation quantiles shifted by stored AVM/MAVM values.
MAVM uses Q_sim-d_minus and Q_sim+d_plus. AVM uses symmetric Q_sim+/-distance as a magnitude diagnostic, not a probability confidence statement. Origins may change with probability; a globally largest distance is never substituted for this search. No metric calculations are repeated.
- Parameters:
valid_case (
ValidCase) – Aligned simulation and experiment observations with their named axes.valid_result (
ValidResult) – Calculated metric fields and observable metadata.observable (
str) – Observable tag identifying matching metadata and observations.metric (
EMetricType) – Metric to select or evaluate.reduce_axes (
tuple[EValidResAxis,], optional) – Epistemic or offset result axes to collapse, in addition to any fixed selections.selectors (
dict[EValidResAxis,int]orNone, optional) – Zero-based indices keyed by result axis; omitted axes follow the operation’s defaults.
- Returns:
ECDFMetricBounds– Metric-shifted and unshifted simulation support limits of shape(*retained_shape, n_probs), with controlling comparison indices.
- profile_epis_nuisance_supports(valid_case, valid_result, observable, metric, *, selectors=None)[source]¶
Profile shifted supports over nuisance, retaining transferable axes.
- Parameters:
valid_case (
ValidCase) – Aligned simulation and experiment observations with their named axes.valid_result (
ValidResult) – Calculated metric fields and observable metadata.observable (
str) – Observable tag identifying matching metadata and observations.metric (
EMetricType) – Metric to select or evaluate.selectors (
dict[EValidResAxis,int]orNone, optional) – Zero-based indices keyed by result axis; omitted axes follow the operation’s defaults.
- Returns:
ECDFMetricBounds– Shifted support limits over the nuisance axes, retaining any unselected transferable and physical dimensions.
- rank_epis_nuisance_cases(supports, *, score=EECDFNuisanceScore.TOTAL_WIDTH)[source]¶
Rank coherent nuisance cases after enveloping transferable uncertainty.
Supply supports with nuisance axes retained and transferable axes reduced. TOTAL_WIDTH integrates shifted width; ADDED_WIDTH integrates the outward extension beyond the unshifted sim envelope. Ranks select actual cases, never a pointwise synthetic median. Equal scores preserve canonical order.
- Parameters:
supports (
ECDFMetricBounds) – Support limits retaining the nuisance dimensions to rank.score (
EECDFNuisanceScore, optional) – Width definition for comparing complete nuisance cases.
- Returns:
ECDFNuisanceRank– Scores and ranking of shape(*retained_shape, n_cases), with a mapping from case rows to nuisance indices.
- calc_avm_over_epis_bounds(sim, exp)[source]¶
Compare all four bound combinations using exact empirical probability mass.
- Parameters:
sim (
ECDFEpisBounds) – Simulation epistemic quantile bounds.exp (
ECDFEpisBounds) – Experimental epistemic quantile bounds in the same physical units.
- Returns:
ECDFMetricBounds– AVM-shifted support limits and distances for the four endpoint combinations.
- calc_mavm_over_epis_bounds(sim, exp, *, alpha=0.05)[source]¶
Construct experimental confidence bounds before epistemic enveloping.
Each original experimental case uses the existing MAVM convention: Student-t(1-alpha, n_unique-1) times population std(unique support)/sqrt(n_unique). The chosen nuisance reduction is then applied to those confidence curves. Synthetic envelope vertices are never treated as experimental observations. All four sim/confidence-bound combinations compete for both shifted limits. This is distinct from MAVM over every original sim–exp case pair.
- Parameters:
sim (
ECDFEpisBounds) – Simulation epistemic quantile bounds.exp (
ECDFEpisBounds) – Experimental epistemic quantile bounds with original samples and selection settings for confidence shifts.alpha (
float, optional) – Experimental confidence parameter used in the Student’s t quantile.
- Returns:
ECDFMetricBounds– MAVM-shifted support limits and directional areas for the four endpoint combinations.
- calc_mavm_bound_pairs(sim_lower, sim_upper, exp_lower, exp_upper, *, alpha=0.05, duplicates=EMAVMDupes.INCLUDE, tol=1e-12)[source]¶
Compare four endpoint pairs and anchor corrections to the supplied sim limits.
The largest d_minus on sim_lower selects the lower correction; the largest d_plus on sim_upper selects the upper correction. These are support-shift diagnostics, not a reduction to the largest MAVM across every sim case.
- Parameters:
sim_lower (
ndarray) – One-dimensional simulation sample for the lower endpoint.sim_upper (
ndarray) – One-dimensional simulation sample for the upper endpoint.exp_lower (
ndarray) – One-dimensional experimental sample for the lower endpoint.exp_upper (
ndarray) – One-dimensional experimental sample for the upper endpoint.alpha (
float, optional) – Experimental confidence parameter used in the Student’s t quantile.duplicates (
EMAVMDupes, optional) – Duplicate handling and empirical-probability integration policy.tol (
float, optional) – Absolute area tolerance for signed contributions, in observation units.
- Returns:
MAVMBoundPairs– All four MAVM comparisons and the two pairs controlling the lower and upper simulation shifts.