distributions#
Provides multiple Distributions.
- class BetaDistribution(alpha: Union[float, int], beta: Union[float, int])#
Bases:
objectAn object which samples values from a beta distributions.
- alpha#
Alpha parameter of the distributions.
- beta#
Beta parameter of the distributions.
- Raises:
TypeError – If alpha is not float or int.
TypeError – If beta is not float or int.
ValueError – If alpha <= 0.
ValueError – If beta <= 0.
Inits BetaDistribution with the provided arguments.
- Parameters:
alpha – Alpha parameter of the distributions.
beta – Beta parameter of the distributions.
- get_random_values(n: int) list[float]#
Samples an array of values with the given shape from the distributions.
- Parameters:
n – The number of values.
- Returns:
an array of randomly sampled values.
- get_samples_from_hypercube(n: int) list[float]#
Samples n values from a hypercube.
- Parameters:
n – the number of samples.
- Returns:
Samples of the distribution, sampled from a hypercube.
- class Constant(value: T)#
Bases:
objectAn object which represents a constant value.
- value#
The value.
- Raises:
TypeError – If value is not a float or int.
Inits the Constant with the provided value.
- Parameters:
value – The scalar used as constant value.
- get_random_values(n: int) list[T]#
Returns an array of the constant value in the given shape.
- Parameters:
n – The number of values.
- Returns:
np.ndarray[float]
- get_samples_from_hypercube(n: int) list[T]#
Samples n values from a hypercube.
- Parameters:
n – the number of samples.
- Returns:
Samples of the distributions, sampled from a hypercube.
- class ContinuousUniformDistribution(min_value: Union[float, int], max_value: Union[float, int])#
Bases:
objectAn object which samples values from a continuous uniform distributions.
- min_value#
the minimal value of the distributions.
- max_value#
the maximal value of the distributions.
- Raises:
TypeError – If min_value is not float or int.
TypeError – If max_value is not float or int.
Inits ContinuousUniformDistribution with the provided arguments.
- Parameters:
min_value – the minimal value of the distributions.
max_value – the maximal value of the distributions.
- get_random_values(n: int) list[float]#
Samples an array with the given distribution.
- Parameters:
n – The number of values.
- Returns:
np.ndarray[float]
- get_samples_from_hypercube(n: int) list[float]#
Samples n values from a hypercube.
- Parameters:
n – the number of samples.
- Returns:
Samples of the distributions, sampled from a hypercube.
- class Distribution(*args, **kwargs)#
Bases:
Protocol[T]A Distribution presents a set of values a property can have.
Note
If no explicit way for sampling with the hypercube, the following code-snippet can probably be used: ``` exactness = 1000 vals = self.get_random_values(n * exactness) vals = np.sort(vals) return [
np.random.choice(vals[i:i+exactness ]) for i in range(0, len(vals), exactness)]
- get_random_values(n: int) list[T]#
Samples a random value due to the type of Distribution.
- Parameters:
n – The number of values.
- get_samples_from_hypercube(n: int) list[T]#
Samples n values from a hypercube.
- Parameters:
n – the number of samples.
- class LogNormalDistribution(mu: Union[float, int], sigma: Union[float, int])#
Bases:
objectAn object which samples values from a log-normal distributions.
- mu#
Mean (“centre”) of the distributions.
- sigma#
Standard deviation (spread or “width”) of the distributions.
- Must be non-negative.
- Raises:
ValueError – If sigma < 0.
TypeError – If mu is not float or int.
TypeError – If sigma is not float or int.
Inits LogNormalDistribution with the provided arguments.
- Parameters:
mu – Mean (“centre”) of the distributions.
sigma – Standard deviation (spread or “width”) of the distributions. Must be non-negative.
- get_random_values(n: int) list[float]#
Samples an array with the given distribution.
- Parameters:
n – The number of values.
- Returns:
np.ndarray[float]
- get_samples_from_hypercube(n: int) list[float]#
Samples n values from a hypercube.
- Parameters:
n – the number of samples.
- Returns:
Samples of the distribution, sampled from a hypercube.
- class NormalDistribution(mu: Union[float, int], sigma: Union[float, int])#
Bases:
objectAn object which samples values from a normal distributions.
- mu#
Mean (“centre”) of the distributions.
- sigma#
Standard deviation (spread or “width”) of the distributions.
- Must be non-negative.
- Raises:
ValueError – If sigma < 0.
TypeError – If mu is not float or int.
TypeError – If sigma is not float or int.
Inits NormalDistribution with the provided arguments.
- Parameters:
mu – Mean (“centre”) of the distributions.
sigma – Standard deviation (spread or “width”) of the distributions. Must be non-negative.
- get_random_values(n: int) list[float]#
Samples an array with the given distribution.
- Parameters:
n – The number of values.
- Returns:
np.ndarray[float]
- get_samples_from_hypercube(n: int) list[float]#
Samples n values from a hypercube.
- Parameters:
n – the number of samples.
- Returns:
Samples of the distribution, sampled from a hypercube.
- class VectorDistribution(values: list[Union[float, int]])#
Bases:
objectAn object which samples values from a list of numbers.
- values#
A list containing values.
- Raises:
IndexError – If values is empty.
TypeError – If values contains a value which is not a float or int.
Inits VectorDistribution with the provided arguments.
- Parameters:
values – A list containing all the valid values.
- get_random_values(n: int) list[float]#
Samples an array of values from the list of values with the given shape.
- Parameters:
n – The number of values.
- Returns:
np.ndarray[float]
- get_samples_from_hypercube(n: int) list[float]#
Samples n values from a hypercube.
- Parameters:
n – the number of samples.
- Returns:
Samples of the distributions, sampled from a hypercube.
- get_random_array_from_distribution(distribution: Distribution[float], shape: tuple[int, ...]) ndarray[Any, dtype[float64]]#
Samples a random array from the given distribution.
- Parameters:
distribution – The distribution to sample from.
shape – The shape of the output array.
- Returns:
A random array sampled from the distribution.
- get_random_value_from_distribution(distribution: Distribution[T]) T#
Samples a random value from the given distribution.
- Parameters:
distribution – The distribution to sample from.
- Returns:
A random value sampled from the distribution.
Defines Beta Distribution. |
|
Defines a Distribution which only has one value. |
|
|
Defines Continuous Uniform Distribution. |
Defines an abstract definition of Distribution. |
|
Provides functions to sample from distributions. |
|
Defines Lognormal Distribution. |
|
Defines the Normal Distribution. |
|
Defines Vector Distribution. |