easy_vic_build.tools.calibrate_func.sampling
Sampling utilities for calibration and parameter exploration.
This module provides commonly used random and quasi-random sampling routines:
uniform and Gaussian sampling,
Latin Hypercube Sampling (LHS),
Sobol and Halton low-discrepancy sequences,
discrete sampling with optional constraints.
Functions
|
Reserved interface for mixed sampling strategies. |
|
Generate random samples using the Halton sequence method within the specified bounds. |
|
Generate random samples using Latin Hypercube Sampling (LHS) method, variant 1, within the specified bounds. |
|
Generate random samples using Latin Hypercube Sampling (LHS) method, variant 2, within the specified bounds. |
|
Generate random samples using the Sobol sequence method within the specified bounds. |
|
Generate random samples from a set of discrete values, optionally with weights. |
Generate random samples from discrete values, with the constraint that the sum of the samples equals target_sum. |
|
|
Generate random samples from a Gaussian (normal) distribution with specified mean and standard deviation. |
|
Generate random samples from a Gaussian distribution with specified mean and standard deviation, and clip the samples to the specified range [low, up]. |
|
Generate random samples from a uniform distribution within the specified bounds. |
|
Generate random integer samples from a uniform distribution within the specified bounds. |
- easy_vic_build.tools.calibrate_func.sampling.sampling_uniform(n_samples, bounds)[source]
Generate random samples from a uniform distribution within the specified bounds.
- Parameters:
n_samples (int) – The number of samples to generate.
bounds (tuple of float) – The lower and upper bounds for the uniform distribution.
- Returns:
samples – The generated random samples.
- Return type:
list of float
- easy_vic_build.tools.calibrate_func.sampling.sampling_uniform_int(n_samples, bounds)[source]
Generate random integer samples from a uniform distribution within the specified bounds.
- Parameters:
n_samples (int) – The number of integer samples to generate.
bounds (tuple of int) – The lower and upper bounds for the uniform distribution.
- Returns:
samples – The generated random integer samples.
- Return type:
list of int
- easy_vic_build.tools.calibrate_func.sampling.sampling_gaussian(n_samples, mean, std)[source]
Generate random samples from a Gaussian (normal) distribution with specified mean and standard deviation.
- Parameters:
n_samples (int) – The number of samples to generate.
mean (float) – The mean of the Gaussian distribution.
std (float) – The standard deviation of the Gaussian distribution.
- Returns:
samples – The generated random samples.
- Return type:
list of float
- easy_vic_build.tools.calibrate_func.sampling.sampling_gaussian_clip(n_samples, mean, std, low=None, up=None)[source]
Generate random samples from a Gaussian distribution with specified mean and standard deviation, and clip the samples to the specified range [low, up].
- Parameters:
n_samples (int) – The number of samples to generate.
mean (float) – The mean of the Gaussian distribution.
std (float) – The standard deviation of the Gaussian distribution.
low (float, optional) – The lower bound for clipping the samples.
up (float, optional) – The upper bound for clipping the samples.
- Returns:
samples – The generated random samples, clipped to the specified range.
- Return type:
numpy.ndarray
- easy_vic_build.tools.calibrate_func.sampling.sampling_LHS_1(n_samples, n_dimensions, bounds)[source]
Generate random samples using Latin Hypercube Sampling (LHS) method, variant 1, within the specified bounds.
- Parameters:
n_samples (int) – The number of samples to generate.
n_dimensions (int) – The number of dimensions for each sample.
bounds (list of tuple) – A list of tuples specifying the lower and upper bounds for each dimension.
- Returns:
samples – The generated Latin Hypercube samples.
- Return type:
numpy.ndarray
- easy_vic_build.tools.calibrate_func.sampling.sampling_LHS_2(n_samples, bounds, seed=None)[source]
Generate random samples using Latin Hypercube Sampling (LHS) method, variant 2, within the specified bounds.
- Parameters:
n_samples (int) – The number of samples to generate.
bounds (list of tuple) – A list of tuples specifying the lower and upper bounds for each dimension.
seed (int, optional) – Seed used by
scipy.stats.qmc.LatinHypercube.
- Returns:
The generated Latin Hypercube samples, scaled to the specified bounds.
- Return type:
numpy.ndarray
- Raises:
ValueError – If any bound does not satisfy
min < max.
- easy_vic_build.tools.calibrate_func.sampling.sampling_Sobol(n_samples, bounds)[source]
Generate random samples using the Sobol sequence method within the specified bounds.
- Parameters:
n_samples (int) – The number of samples to generate.
bounds (list of tuple) – A list of tuples specifying the lower and upper bounds for each dimension.
- Returns:
The generated Sobol samples, scaled to the specified bounds.
- Return type:
numpy.ndarray
- easy_vic_build.tools.calibrate_func.sampling.sampling_Halton(n_samples, bounds)[source]
Generate random samples using the Halton sequence method within the specified bounds.
- Parameters:
n_samples (int) – The number of samples to generate.
bounds (list of tuple) – A list of tuples specifying the lower and upper bounds for each dimension.
- Returns:
The generated Halton samples, scaled to the specified bounds.
- Return type:
numpy.ndarray
- easy_vic_build.tools.calibrate_func.sampling.sampling_discrete(discrete_values, n_samples, weights=None)[source]
Generate random samples from a set of discrete values, optionally with weights.
- Parameters:
discrete_values (array-like) – A list or array of discrete values to sample from.
n_samples (int) – The number of samples to generate.
weights (array-like, optional) – The weights associated with the discrete values. If None, the values are assumed to be equally likely.
- Returns:
samples – The generated discrete samples.
- Return type:
numpy.ndarray
- easy_vic_build.tools.calibrate_func.sampling.sampling_discrete_constrained(discrete_values, target_sum, n_samples)[source]
Generate random samples from discrete values, with the constraint that the sum of the samples equals target_sum.
- Parameters:
discrete_values (array-like) – A list or array of discrete values to sample from.
target_sum (int) – The target sum for the generated samples.
n_samples (int) – The number of samples to generate.
- Returns:
samples – The generated discrete samples with the constraint on their sum.
- Return type:
numpy.ndarray
- easy_vic_build.tools.calibrate_func.sampling.mixed_sampling(n_samples)[source]
Reserved interface for mixed sampling strategies.
- Parameters:
n_samples (int) – Requested number of samples.
- Returns:
This function currently has no implementation.
- Return type:
None
Notes
This function is intentionally left as a placeholder for future extension.