# Uq\[Py\]Lab v1.0 - How to assign different options for inference of two (or more) marginal distributions

**URL:** <https://uqworld.org/t/uq-py-lab-v1-0-how-to-assign-different-options-for-inference-of-two-or-more-marginal-distributions/4081>\
**Category:** Community Q&A and How To\
**Tags:** input, python\
**Created:** [July 5, 2025, 4:24pm UTC](https://uqworld.org/t/uq-py-lab-v1-0-how-to-assign-different-options-for-inference-of-two-or-more-marginal-distributions/4081 "2025-07-05T16:24:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacek\_Swiegoda](https://uqworld.org/user_avatar/uqworld.org/jacek_swiegoda/32/1735_2.png) [@Jacek\_Swiegoda](https://uqworld.org/u/Jacek_Swiegoda)\
**Post date:** [July 5, 2025, 4:24pm UTC](https://uqworld.org/t/uq-py-lab-v1-0-how-to-assign-different-options-for-inference-of-two-or-more-marginal-distributions/4081/1 "2025-07-05T16:24:25Z")

</div>

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:

```matlab
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:

```matlab
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()

```

---

<div class="post-metadata">

**Author:** ![Jacek\_Swiegoda](https://uqworld.org/user_avatar/uqworld.org/jacek_swiegoda/32/1735_2.png) [@Jacek\_Swiegoda](https://uqworld.org/u/Jacek_Swiegoda)\
**Post date:** [July 6, 2025, 7:30am UTC](https://uqworld.org/t/uq-py-lab-v1-0-how-to-assign-different-options-for-inference-of-two-or-more-marginal-distributions/4081/2 "2025-07-06T07:30:16Z")

</div>

Ok, I have managed to solve this.

The syntax

`iOpts['Marginals'][1]['Bounds']`

will not work unless both marginals are specified in analogy to defining input marginals:

```matlab
InputOpts2 = {
    "Copula": {"Type": "Independent"},
    "Inference": {
        "Data": X_LHS.tolist()
        },
    "Marginals": [{
        "Type": ['Gaussian', 'Beta', 'Exponential', 'Weibull', 'LogNormal'],
        'Bounds': [0,3.6]
    },
    {
        "Type": ['Gaussian', 'LogNormal'],
        'Bounds': [0,0.8]
    }]
}

```
