pyvale.validation.metricstrategy module

Metric strategies and compact tagged metric results.

class MetricMAVM(*, alpha=0.05, duplicates=EMAVMDupes.INCLUDE, tol=1e-12)[source]

Bases: IValidMetric

Calculate directional area discrepancies with experimental confidence shifts.

Variables:
  • alpha (float) – Experimental confidence parameter used for the Student’s t shift.

  • duplicates (EMAVMDupes) – Duplicate handling and empirical-probability integration policy.

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

__init__(*, alpha=0.05, duplicates=EMAVMDupes.INCLUDE, tol=1e-12)[source]

Configure MAVM confidence and duplicate handling.

Parameters:
  • alpha (float, optional) – Experimental confidence parameter used for the Student’s t shift.

  • duplicates (EMAVMDupes, optional) – Duplicate handling and empirical-probability integration policy.

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

alpha
duplicates
tol
get_kind()[source]

Identify the validation metric.

Returns:

EMetricType – MAVM.

get_scale()[source]

Declare the scale of the metric outputs.

Returns:

EMetricScale – PHYSICAL.

get_comparison()[source]

Declare how simulation and experimental samples are compared.

Returns:

EMetricCompare – DISTRIB.

get_outputs()[source]

Declare the output tags in numerical result order.

Returns:

tuple[EMetricOut, ] – D_PLUS, D_MINUS.

calc(sim, exp)[source]

Calculate the metric for a single pair of conditional samples.

Parameters:
  • sim (ndarray) – Simulation observations of shape (n_sim_aleatory,). NaNs are omitted.

  • exp (ndarray) – Experimental observations of shape (n_exp_aleatory,). NaNs are omitted.

Returns:

MAVMResult – Directional areas in observable units and their supporting ECDF data.

class MetricAVM[source]

Bases: IValidMetric

Calculate the first Wasserstein distance between empirical distributions.

get_kind()[source]

Identify the validation metric.

Returns:

EMetricType – AVM.

get_scale()[source]

Declare the scale of the metric outputs.

Returns:

EMetricScale – PHYSICAL.

get_comparison()[source]

Declare how simulation and experimental samples are compared.

Returns:

EMetricCompare – DISTRIB.

get_outputs()[source]

Declare the output tags in numerical result order.

Returns:

tuple[EMetricOut, ] – DISTANCE.

calc(sim, exp)[source]

Calculate the metric for a single pair of conditional samples.

Parameters:
  • sim (ndarray) – Simulation observations of shape (n_sim_aleatory,). NaNs are omitted.

  • exp (ndarray) – Experimental observations of shape (n_exp_aleatory,). NaNs are omitted.

Returns:

ScalarMetricResult – First Wasserstein distance in the original observation units.

class MetricKS[source]

Bases: IValidMetric

Calculate the maximum probability difference between two empirical CDFs.

get_kind()[source]

Identify the validation metric.

Returns:

EMetricType – KS.

get_scale()[source]

Declare the scale of the metric outputs.

Returns:

EMetricScale – DIMLESS_01.

get_comparison()[source]

Declare how simulation and experimental samples are compared.

Returns:

EMetricCompare – DISTRIB.

get_outputs()[source]

Declare the output tags in numerical result order.

Returns:

tuple[EMetricOut, ] – STATISTIC.

calc(sim, exp)[source]

Calculate the metric for a single pair of conditional samples.

Parameters:
  • sim (ndarray) – Simulation observations of shape (n_sim_aleatory,). NaNs are omitted.

  • exp (ndarray) – Experimental observations of shape (n_exp_aleatory,). NaNs are omitted.

Returns:

ScalarMetricResult – Maximum absolute CDF difference in [0, 1].

class MetricCVM[source]

Bases: IValidMetric

Calculate the two-sample Cramér–von Mises statistic.

get_kind()[source]

Identify the validation metric.

Returns:

EMetricType – CVM.

get_scale()[source]

Declare the scale of the metric outputs.

Returns:

EMetricScale – DIMLESS.

get_comparison()[source]

Declare how simulation and experimental samples are compared.

Returns:

EMetricCompare – DISTRIB.

get_outputs()[source]

Declare the output tags in numerical result order.

Returns:

tuple[EMetricOut, ] – STATISTIC.

calc(sim, exp)[source]

Calculate the metric for a single pair of conditional samples.

Parameters:
  • sim (ndarray) – Simulation observations of shape (n_sim_aleatory,). NaNs are omitted.

  • exp (ndarray) – Experimental observations of shape (n_exp_aleatory,). NaNs are omitted.

Returns:

ScalarMetricResult – Dimensionless two-sample Cramér–von Mises statistic.

class MetricRMSE[source]

Bases: IValidMetric

Calculate root mean square error for paired observations.

get_kind()[source]

Identify the validation metric.

Returns:

EMetricType – RMSE.

get_scale()[source]

Declare the scale of the metric outputs.

Returns:

EMetricScale – PHYSICAL.

get_comparison()[source]

Declare how simulation and experimental samples are compared.

Returns:

EMetricCompare – PAIRED.

get_outputs()[source]

Declare the output tags in numerical result order.

Returns:

tuple[EMetricOut, ] – ERROR.

calc(sim, exp)[source]

Calculate the metric for a single pair of conditional samples.

Parameters:
  • sim (ndarray) – Simulation observations of shape (n_pairs,). Both arrays follow the same pair order. Pairs containing NaN are omitted.

  • exp (ndarray) – Experimental observations of shape (n_pairs,). Both arrays follow the same pair order. Pairs containing NaN are omitted.

Returns:

ScalarMetricResult – Root mean square error in the original units.

class MetricRelErr(*, normalisation=ERelErrNorm.EXP_MAX, constant=None)[source]

Bases: IValidMetric

Calculate a normalised mean absolute error for paired observations.

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

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

__init__(*, normalisation=ERelErrNorm.EXP_MAX, constant=None)[source]

Configure the reference magnitude for relative error.

Parameters:
  • 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.

normalisation
constant
get_kind()[source]

Identify the validation metric.

Returns:

EMetricType – REL_ERR.

get_scale()[source]

Declare the scale of the metric outputs.

Returns:

EMetricScale – DIMLESS.

get_comparison()[source]

Declare how simulation and experimental samples are compared.

Returns:

EMetricCompare – PAIRED.

get_outputs()[source]

Declare the output tags in numerical result order.

Returns:

tuple[EMetricOut, ] – ERROR.

calc(sim, exp)[source]

Calculate the metric for a single pair of conditional samples.

Parameters:
  • sim (ndarray) – Simulation observations of shape (n_pairs,). Both arrays follow the same pair order. Pairs containing NaN are omitted.

  • exp (ndarray) – Experimental observations of shape (n_pairs,). Both arrays follow the same pair order. Pairs containing NaN are omitted.

Returns:

ScalarMetricResult – Dimensionless relative error using the configured normalisation.