UQTestFun#
Module containing the concrete implementation of UQ test functions.
This module provides the UQTestFun class, which encapsulates an evaluation function, a probabilistic input model, and optional parameters into a single callable object for uncertainty quantification test functions.
- class uqtestfuns.core.uqtestfun.UQTestFun(evaluate: Callable, prob_input: ProbInput, parameters: Parameters | None = None, name: str | None = None, description: str | None = None, output_dimension: int = 1)#
A concrete class for UQ test functions.
Encapsulates an evaluation function, a probabilistic input model, optional parameters, and metadata into a single callable object.
- Parameters:
evaluate (Callable) – The evaluation function. Must accept a 2D numpy array of shape
(n_samples, input_dimension)and return an array of shape(n_samples,)or(n_samples, output_dimension). If parameters are provided, they are passed as keyword arguments.prob_input (ProbInput) – The probabilistic input model defining the input space and the distribution of the input variables.
parameters (Parameters, optional) – The parameter set of the UQ test function. If provided, passed as keyword arguments to
evaluate. Default is None.name (str, optional) – The name of the UQ test function. Default is None.
description (str, optional) – A human-readable description of the UQ test function. Default is None.
output_dimension (int, optional) – The number of output values produced per input point. Default is 1.
- Raises:
TypeError – If any argument has an incorrect type.
- __init__(evaluate: Callable, prob_input: ProbInput, parameters: Parameters | None = None, name: str | None = None, description: str | None = None, output_dimension: int = 1)#
- property description: str | None#
Get the description of the UQ test function.
- Returns:
The description of the test function, or None if not set.
- Return type:
Optional[str]
- get_sample(sample_size: int = 1, rng: Generator | int | None = None) ndarray#
Generate a sample of output values from the UQ test function.
Generates random input points from the probabilistic input model and evaluates the test function at those points. Unlike
prob_input.get_sample(), which returns input samples, this method returns the corresponding function output values.- Parameters:
sample_size (int, optional) – The number of sample points to generate. Default is 1.
rng (Union[np.random.Generator, int, None], optional) – Random number generator or seed for reproducibility. Accepts a
np.random.Generator, an integer seed, or None for the default generator. Default is None.
- Returns:
Output array of shape
(sample_size,)ifoutput_dimensionis 1, or(sample_size, output_dimension)otherwise.- Return type:
np.ndarray
- property input_dimension: int#
Get the input dimension of the UQ test function.
- Returns:
The dimension of the input space, determined by the probabilistic input model.
- Return type:
int
- property name: str | None#
Get the name of the UQ test function.
- Returns:
The name of the test function, or None if not set.
- Return type:
Optional[str]
- property output_dimension: int#
Get the output dimension of the UQ test function.
- Returns:
The dimension of the output space, representing the number of output values produced by the test function for each input.
- Return type:
int
- property parameters: Parameters | None#
Get the parameters of the UQ test function.
- Returns:
The parameters of the test function, or None if not set.
- Return type:
Optional[Parameters]