Uncertainty#
This module contains all uncertainty related functionality.
The entry point for performing an uncertainty analysis is probabilistic_library.project.UncertaintyProject. A model can be attached to an uncertainty project, then stochastic variables, correlation matrix and settings are provided. When the uncertainty project is run, an uncertainty result is generated, which contains a stochastic variable, which resembles the variation of the output of the model.
- class UncertaintyMethod(value)[source]#
Bases:
EnumEnumeration which defines the algorithm to perform an uncertainty analysis
- crude_monte_carlo = 'crude_monte_carlo'#
- directional_sampling = 'directional_sampling'#
- form = 'form'#
- fosm = 'fosm'#
- importance_sampling = 'importance_sampling'#
- numerical_integration = 'numerical_integration'#
- class UncertaintyResult(id, variables)[source]#
Bases:
FrozenObjectContains the result of an uncertainty analysis for a specific output parameter
An uncertainty analysis results in a stochastic variable. The characteristics of this stochastic variable describe the uncertainty of the output parameter. Depending on the uncertainty algorithm different distributions may be used.
- Parameters:
id (int)
variables (list[Stochast])
- get_plot(xmin=None, xmax=None)[source]#
Gets a plot object of the resulting stochastic variable
- Return type:
<module ‘matplotlib.pyplot’ from ‘/home/runner/.cache/pypoetry/virtualenvs/probabilistic-library-UeuwKTS6-py3.11/lib/python3.11/site-packages/matplotlib/pyplot.py’>
- Parameters:
xmin (float)
xmax (float)
- get_plot_realizations(var_x=None, var_y=None)[source]#
Gets a plot object of a scatter-plot of realizations performed by the uncertainty analysis. The x-y coordinates correspond with realization input values. Only available when UncertaintySettings.save_realizations was set in the UncertaintySettings.
- Parameters:
- Return type:
<module ‘matplotlib.pyplot’ from ‘/home/runner/.cache/pypoetry/virtualenvs/probabilistic-library-UeuwKTS6-py3.11/lib/python3.11/site-packages/matplotlib/pyplot.py’>
- property identifier: str#
Identification of the output parameter
- property messages: list[Message]#
List of messages generated by the reliability algorithm. Depends on the setting UncertaintySettings.save_messages whether this list is provided
- plot(xmin=None, xmax=None)[source]#
Shows a plot of the resulting stochastic variable
- Parameters:
xmin (float)
xmax (float)
- plot_realizations(var_x=None, var_y=None)[source]#
Shows a scatter-plot of realizations performed by the uncertainty analysis. The x-y coordinates correspond with realization input values. Only available when UncertaintySettings.save_realizations was set in the UncertaintySettings.
- print(decimals=4)[source]#
Prints the resulting stochastic variable and quantile samples.
- Parameters:
decimals (int, optional) – The number of decimals to print
- property quantile_realizations: list[Evaluation]#
List of samples corresponding with the list of quantiles in the uncertainty settings. The samples in this list are the closest samples to the given quantiles
- property realizations: list[Evaluation]#
List of samples calculated by the uncertainty algorithm. Depends on the setting UncertaintySettings.save_realizations whether this list is provided
- class UncertaintySettings[source]#
Bases:
FrozenObjectSettings of an uncertainty algorithm
Settings of all uncertainty algorithms are combined in this class. Often settings only apply to a selected number of algorithms. Settings per variable are listed in stochast_settings.
The settings are divided into the following categories:
Algorithm settings: Settings which are used to control the algorithm, such as the number of allowed samples and the convergence criterion.
Runtime settings: Settings to control how model executions take place and which additional output to produce. These settings do not influence the calculated uncertainty.
- property calculate_correlations: bool#
Indicates that correlations between output parameters must be calculated
- property calculate_input_correlations: bool#
Indicates that correlations between output parameters and input parameters must be calculated
- property derive_samples_from_variation_coefficient: bool#
Indicates that the number of samples is derived from the variation coefficient and the probability of failure (only for Crude Monte Carlo)
- property global_step_size: float#
Step size between fragility values, which is the result if a FORM calculation
- property gradient_type: GradientType#
Method to determine the gradient of a model
- property is_repeatable_random: bool#
Indicates whether in each run the same random samples will be generated
- property max_parallel_processes: int#
The number of parallel executions of model evaluations
- property maximum_directions: int#
The maximum number of directions to be used, only for directional sampling
- property maximum_iterations: int#
The maximum number of iterations to be used, only for FORM
- property maximum_samples: int#
The maximum number of samples to be used
- property maximum_u: float#
The maximum u-value to be applied to a stochastic variable, used for FORM
- property minimum_directions: int#
The minimum number of directions to be used, only for directional sampling
- property minimum_samples: int#
The minimum number of samples to be used
- property minimum_u: float#
The minimum u-value to be applied to a stochastic variable, used for FORM
- property probability_for_convergence: float#
Probability to which the convergence applies
The convergence is calculated as if it were a reliability analysis. The reliability analysis is tuned in such a way (by modification of the failure definition) that it produces the given probability.
- property quantiles: list[ProbabilityValue]#
List of quantiles of the output parameter, which must be calculated
- property random_seed: int#
Seed number for the random generator
- property reuse_calculations: bool#
Indicates whether prior model results will be reused by the uncertainty analysis.
This will speed up calculations when several analyses are performed, for which the same realizations will have to be executed, for example a Crude Monte Carlo analysis for different output parameters. But when a modification to the model is made, which is beyond the scope of the model definition, this leads to undesired results
- property save_messages: bool#
Indicates whether messages generated by the uncertainty analysis will be saved If saved, messages will be part of the design point
- property save_realizations: bool#
Indicates whether samples should be saved If saved, the samples will be part of the design point
- property step_size: float#
Step size in calculating the model gradient, used by FORM
- property stochast_settings: list[StochastSettings]#
List of settings specified per stochastic variable
- property uncertainty_method: UncertaintyMethod#
Defines the uncertainty algorithm
- property variance_factor: float#
Variance factor, used by importance sampling
- property variation_coefficient: float#
Convergence criterion, used by Monte Carlo family algorithms