Hello.
I wrote a test script in Python which I wanted to perform inference of marginals based on data generated from defined distributions (in analogy to the example in uqlab docs).
There are two random variables and I would like to set different parameters of the inference analysis for each of them.
According to the instructions, this can be done with syntax e.g.
"iOpts['Marginals'][ii][Bounds]".
When I try to do this, I get a Python error:
InputOpts2["Marginals"][1] = {
IndexError: list assignment index out of range
which means that the index ii=1 was not found.
Can I ask for help on how to define different parameters for more than one input variable?
Here’s the script:
from uqpylab import sessions, display_util
mySession = sessions.cloud()
uq = mySession.cli
mySession.reset()
display_util.load_plt_defaults()
uq_colors = display_util.get_uq_color_order()
uq.rng(100, 'twister')
InputOpts1 = {
'Marginals': [
{
'Type': 'Lognormal',
'Moments': [3,1.2],
'Bounds': [0,3.6]
},
{
'Type': 'Beta',
'Parameters': [6,4],
'Bounds': [0,0.8]
}
]
}
myInput = uq.createInput(InputOpts1)
uq.print(myInput)
uq.display(myInput)
X_LHS = uq.getSample(N=1000, Method='LHS')
InputOpts2 = {
"Copula": {"Type": "Independent"},
"Inference": {
"Data": X_LHS.tolist()
},
"Marginals": [{
"Inference": {
"Criterion": 'ML'
}
}]
}
InputOpts2["Marginals"][0] = {
"Type": ['Gaussian', 'Exponential', 'Weibull', 'LogNormal'],
"Bounds": [0,3.6]
}
InputOpts2["Marginals"][1] = {
"Type": ['Gaussian', 'LogNormal'],
'Bounds': [0,0.8]
}
InputHat1 = uq.createInput(InputOpts2)
fig = uq.display(InputHat1)
uq.print(InputHat1)
mySession.quit()