chromasurr.uq module

chromasurr.uq.latin_hypercube_sampler(bounds, *, seed=None)[source]

Create a Latin hypercube sampler for given parameter bounds.

Parameters:
  • bounds (Sequence[tuple[float, float]]) – Sequence of (min, max) pairs for each model input dimension.

  • seed (int, optional) – Seed for random number generator to ensure reproducibility.

Returns:

Callable[[int], ndarray of float] – Function that takes an integer n and returns an (n, len(bounds)) array of sampled inputs.

chromasurr.uq.perform_monte_carlo_uq(*, surrogate, sample_input, metrics=None, metric=None, n_samples=10000)[source]

Propagate input uncertainty via Monte Carlo sampling using a surrogate model.

Parameters:
  • surrogate (Surrogate) – Trained surrogate model providing predict and predict_var.

  • sample_input (Callable[[int], ndarray]) – Function that generates an array of shape (n_samples, num_vars) of input samples.

  • metrics (str or Sequence[str], optional) – Metric name or list of metric names to evaluate. If None, uses surrogate.metrics.

  • metric (str, optional) – Legacy single-metric alias; if provided, metrics must be None.

  • n_samples (int, default 10000) – Number of Monte Carlo samples to draw.

Returns:

dict or dict of dict – If a single metric, returns a dict with keys: 'mean', 'variance', 'var_between', 'var_within', 'quantiles', 'y_means', 'y_vars'. If multiple metrics, returns a mapping from metric name to its stats.