pystra.model.StochasticModel#
Use it: User guide · Worked example · Theory
- class StochasticModel(joint_distribution=None)[source]#
Bases:
objectNamed random variables, constants and their dependence model.
Random variables and constants are added with
add_variable(). Random-variable insertion order defines correlation rows and columns and the columns accepted byLimitState.evaluate().- Parameters:
joint_distribution (
JointDistribution|None) – Initial marginals and explicit copula. Omit it to add variables individually and specify physical correlation or a copula later.
Notes
The names and marginal-distribution properties expose the stored lists; the constants property is a read-only view of stored constant values.
Methods
Add to the cumulative number of limit-state evaluations.
Add a random variable or constant to the model.
Return the cumulative number of limit-state evaluations.
Return the explicit copula, or None for physical Pearson input.
Return the stored physical Pearson matrix, or None before variables exist.
Return marginals plus the explicit or calibrated Gaussian copula.
Return the number of random variables, excluding constants.
Return the stored marginal list in random-variable insertion order.
Return the stored Nataf correlation, or None before it is computed.
Return the stored names in variable and constant insertion order.
Return the stored mapping of random-variable names to distributions.
Replace legacy Pearson dependence with an explicit copula.
Set the physical correlation matrix, replacing any copula.
Replace the stored marginal list without copying or reordering it.
Store a Nataf correlation matrix without copying or validating it.
Return the random variable called name.
- add_variable(obj)[source]#
Add a random variable or constant to the model.
- Parameters:
obj (
Distribution|Constant) – The variable to add. Distributions are treated as random variables; Constants are stored separately and passed as fixed values to the limit-state function.- Raises:
ModelError – If obj is not a Distribution or Constant, or if a variable with the same name already exists. Add all random variables before explicitly setting correlation or a copula.
- Return type:
None
- property constants: Mapping[str, float]#
Read-only mapping of constant names to values.
- property names: list[str]#
List of all variable and constant names, in insertion order.
- property n_marg: int#
Number of marginal (stochastic) distributions.
- property marginal_distributions: list[Distribution]#
List of marginal Distribution objects.
- property correlation: ndarray | None#
Correlation matrix (n × n numpy array).
- Setter accepts:
CorrelationMatrix|ArrayLike
- property copula: Copula | None#
Explicit dependence specification, or None for legacy Pearson input.
- Setter accepts:
- property modified_correlation: ndarray | None#
Modified (Nataf) correlation matrix Ro.
- property call_function: int#
Cumulative number of limit-state function evaluations.
- get_variables()[source]#
Return the stored mapping of random-variable names to distributions.
- Return type:
OrderedDict[str,Distribution]
- get_names()[source]#
Return the stored names in variable and constant insertion order.
- Return type:
list[str]
- get_len_marginal_distributions()[source]#
Return the number of random variables, excluding constants.
- Return type:
int
- get_marginal_distributions()[source]#
Return the stored marginal list in random-variable insertion order.
- Return type:
list[Distribution]
- set_marginal_distributions(marg)[source]#
Replace the stored marginal list without copying or reordering it.
This low-level setter does not update names, the variable mapping or dependence. Callers must keep those structures consistent.
- Return type:
None
- set_correlation(obj)[source]#
Set the physical correlation matrix, replacing any copula.
Accepts a
CorrelationMatrix, or an array that is valid as one, and raisesModelErrorotherwise.- Return type:
None
- get_correlation()[source]#
Return the stored physical Pearson matrix, or None before variables exist.
Raises ValueError when dependence is specified by an explicit copula, which does not in general determine the physical Pearson matrix.
- Return type:
ndarray|None
- set_copula(copula)[source]#
Replace legacy Pearson dependence with an explicit copula.
- Return type:
None
- get_copula()[source]#
Return the explicit copula, or None for physical Pearson input.
- Return type:
Copula|None
- get_joint_distribution()[source]#
Return marginals plus the explicit or calibrated Gaussian copula.
- Return type:
- set_modified_correlation(correlation)[source]#
Store a Nataf correlation matrix without copying or validating it.
- Return type:
None
- get_modified_correlation()[source]#
Return the stored Nataf correlation, or None before it is computed.
- Return type:
ndarray|None