Sampling Utilities
Low-discrepancy and quasi-random sampling methods for parameter space exploration. Used by ensemble initialisation and parameter-space analysis.
Structured sampling utilities for parameter space exploration.
Provides low-discrepancy and quasi-random sampling methods used by both parameter initialization (base_pool.add_noise) and ensemble averaging (EnsembleAveragingHook.init_base_parameters).
- generate_ensemble_samples(n_samples, n_dims, method='lhs', seed=0)[source]
Generate samples for parameter space exploration.
- Parameters:
- Returns:
Shape (n_samples, n_dims) with values in [0, 1] for structured methods, or standard normal for “gaussian”
- Return type:
np.ndarray
- generate_param_space_samples(params, n_samples, method, seed=0, exclude_keys=_DEFAULT_EXCLUDE_KEYS)[source]
Generate structured samples in the parameter space defined by a params dict.
Identifies the trainable dimensions across all parameter arrays, generates low-discrepancy samples in that joint space, and returns a mapping so callers can distribute columns back to individual parameters.
- Parameters:
params (Dict[str, Any]) – Parameter dictionary. Values are arrays with shape (n_sets, …). The first dimension is the “set” dimension.
n_samples (int) – Number of sample points to generate
method (str) – Sampling method passed to generate_ensemble_samples
seed (int) – Random seed for reproducibility
exclude_keys (tuple) – Keys to skip (not perturbed)
- Returns:
samples (np.ndarray) – Shape (n_samples, total_dims). Values in [0, 1] for structured methods, or N(0, 1) for “gaussian”.
trainable_keys (List[str]) – Ordered list of keys that were included
dim_map (Dict[str, Tuple[int, int, tuple]]) – key -> (start_col, n_dims, shape_per_sample) so callers can slice
samples[:, start_col:start_col + n_dims].reshape((n_samples,) + shape_per_sample)
- Return type:
Tuple[ndarray, List[str], Dict[str, Tuple[int, int, tuple]]]