This example showcases how to define a probabilistic input model with or without a copula dependency.
from uqpylab import sessions
# Start the session
mySession = sessions.cloud()
# (Optional) Get a convenient handle to the command line interface
uq = mySession.cli
# Reset the session
mySession.reset()
uqpylab.sessions :: INFO :: A new session (2d6a97142a234229becd9ce54040e29c) started. uqpylab.sessions :: INFO :: Reset successful.
The probabilistic input model consists of two variables:
$X_1 \sim \mathcal{N}(0, 1)$
and
$X_2 \sim \mathcal{B}(1, 3)$
InputOpts = {
'Marginals': [
{
'Type': 'Gaussian',
'Parameters': [0,1]
},
{
'Type': 'Beta',
'Parameters': [1,3]
}
]
}
By default, the variables are considered independent.
Create an INPUT object based on the specified marginals:
myInputIndependent = uq.createInput(InputOpts)
Print a report of the INPUT object:
uq.print(myInputIndependent)
============================================================== Input object name: Input 1 Dimension(M): 2 Marginals: Index | Name | Type | Parameters | Moments -------------------------------------------------------------------------- 1 | X1 | Gaussian | 0.000e+00, 1.000e+00 | 0.000e+00, 1.000e+00 2 | X2 | Beta | 1.000e+00, 3.000e+00 | 2.500e-01, 1.936e-01 Copula: Type: Independent Dimension: 2 Variables coupled: [1 2] ==============================================================
The marginal distributions of the probabilistic input model are already defined inside the structure InputOpts
. A dependency following a Gaussian copula is added as follows:
InputOpts['Copula'] = {'Type': 'Gaussian',
'RankCorr': [[1, 0.8],[0.8, 1]] # the Spearman corr. matrix
}
Create an INPUT object based on the specified marginals and copula:
myInputDependent = uq.createInput(InputOpts)
Print a report of the INPUT object:
uq.print(myInputDependent)
============================================================== Input object name: Input 2 Dimension(M): 2 Marginals: Index | Name | Type | Parameters | Moments -------------------------------------------------------------------------- 1 | X1 | Gaussian | 0.000e+00, 1.000e+00 | 0.000e+00, 1.000e+00 2 | X2 | Beta | 1.000e+00, 3.000e+00 | 2.500e-01, 1.936e-01 Copula: Type: Gaussian Dimension: 2 Variables coupled: [1 2] Parameters: [+1.0000 +0.8135 ; +0.8135 +1.0000 ] ==============================================================
Each of the generated INPUT objects can be quickly visualized using the function uq.display
.
For the independent INPUT object:
fig = uq.display(myInputIndependent)
fig.show()
For the dependent INPUT object:
fig = uq.display(myInputDependent)
fig.show()
mySession.quit()
uqpylab.sessions :: INFO :: Session 2d6a97142a234229becd9ce54040e29c terminated.
True