pyvale.validation.metrics module

Core 1D validation metrics calculations.

Includes Modified Area Validation Metric (MAVM), classical Area Validation Metric (AVM / 1-Wasserstein), Kolmogorov-Smirnov distance, Cramér-von Mises, and deterministic error metrics.

calc_mavm_1d(sim_data, exp_data, *, alpha=0.05, duplicates=EMAVMDupes.REJECT, tol=1e-12)[source]

Calculates the Modified Area Validation Metric (MAVM) between 1D arrays.

Implements the corrected fullfieldvalmetrics MAVM algorithm, including its fixed unequal-sample probability step. The result values match the established fullfield validation workflow.

Parameters:
  • sim_data (np.ndarray) – 1D array of simulation realization values.

  • exp_data (np.ndarray) – 1D array of experimental observation values.

  • alpha (float, optional) – Legacy Student’s t quantile parameter: t.ppf(1-alpha, n_unique-1). Confidence shifts use the population standard deviation of unique experimental support divided by sqrt(n_unique), including with INCLUDE.

  • duplicates (EMAVMDupes, optional) – REJECT preserves fullfieldvalmetrics behaviour and requires unique observations. INCLUDE supports repeated observations using weighted ECDF probability steps.

  • tol (float, optional) – Absolute area tolerance for signed contributions, in observation units.

Returns:

MAVMResult – Complete result dataclass with d+, d-, and CDF data.

calc_avm_1d(model_data, exp_data)[source]

Calculates classical Area Validation Metric (1-Wasserstein distance).

Parameters:
  • model_data (np.ndarray) – 1D array of model realizations.

  • exp_data (np.ndarray) – 1D array of experimental observations.

Returns:

float – 1-Wasserstein / AVM distance between model and experiment.

calc_ks_1d(model_data, exp_data)[source]

Calculates Kolmogorov-Smirnov validation distance (L-infinity on CDFs).

Parameters:
  • model_data (np.ndarray) – 1D array of model realizations.

  • exp_data (np.ndarray) – 1D array of experimental observations.

Returns:

float – Two-sample Kolmogorov-Smirnov test statistic.

calc_cvm_1d(model_data, exp_data)[source]

Calculates Cramér-von Mises validation distance (L2 norm on CDFs).

Parameters:
  • model_data (np.ndarray) – 1D array of model realizations.

  • exp_data (np.ndarray) – 1D array of experimental observations.

Returns:

float – Two-sample Cramér-von Mises test statistic.

class ERelErrNorm(*values)[source]

Bases: Enum

Choose the reference magnitude used by relative error.

EXP_MAX = 1
SIM_MAX = 2
CONSTANT = 3
class DetMetricResult(abs_err, rel_err, rmse, nmse)[source]

Bases: object

Store errors calculated from matched simulation and experimental observations.

Variables:
  • abs_err (float) – Mean absolute error in observable units.

  • rel_err (float) – Mean absolute error divided by the selected reference magnitude.

  • rmse (float) – Root mean square error in observable units.

  • nmse (float) – Mean square error divided by the variance of the experimental observations. NaN when that variance is effectively zero.

abs_err
rel_err
rmse
nmse
__init__(abs_err, rel_err, rmse, nmse)
calc_deterministic_metrics_1d(sim_valid, exp_valid, *, normalisation=ERelErrNorm.EXP_MAX, constant=None)[source]

Return paired errors; NMSE is NaN for variance at or below the zero tolerance.

Parameters:
  • sim_valid (float or ndarray) – Simulation observations of shape (n_aleatory,), paired by index with exp_valid.

  • exp_valid (float or ndarray) – Experimental observations of shape (n_aleatory,) in the same units. Pairs containing NaN are omitted.

  • normalisation (ERelErrNorm, optional) – Reference used to scale the mean absolute paired error.

  • constant (float or None, optional) – Positive fixed normalisation value for CONSTANT mode; otherwise None.

Returns:

DetMetricResult – Mean absolute error, relative error, RMSE and NMSE for the remaining pairs.