I’ve understood that it’s possible to deal with a model with discrete scenarios using a discrete variable : your explanation is very clear and helpfull. This being said, I have a question.

Let’s consider the program below. The model is very simple. There are two scenarios and different parameters are used to caculate the output of the model depending on the scenario. The sum of all “Si” is not equal to 1 but 0.5, so I think there is a problem. What is wrong ? Is it that variables have become dependent ?

Thank you

———————————————————————————————-

from SALib.sample import saltelli

from SALib.analyze import sobol

# from SALib.util import read_param_file

import numpy as np

import matplotlib.pyplot as plt

calc_second_order = True

def Model(x):

iterations = np.shape(x)[0]

Y = np.empty((iterations,))

for i in range(iterations):

P1, P2, P3, P4, Pab = x[i][0], x[i][1], x[i][2], x[i][3], round(x[i][4])

if Pab == 0 :

Yi = P1 + P2

else :

Yi = P3 + P4

Y[i] = Yi

return Y

# problem definition

prob = {

‘num_vars’: 5,

‘names’: [‘P1′,’P2′,’P3′,’P4′,’Pab’],

# ‘groups’:[‘g1′,’g1′,’g2′,’g2′,’g3’],

‘bounds’: [[0.0, 1.0],[0.0, 1.0], [0.0, 1.0], [0.0, 1.0],

[0, 1.0]],

‘dists’: [‘unif’, ‘unif’, ‘unif’, ‘unif’,

‘unif’]

}

# generating parameter values

param = saltelli.sample(prob, 1000, calc_second_order)

# calculating model output values

Y = Model(param)

# completing Sobol’ sensitivity analysis

Si_code = sobol.analyze(prob, Y, calc_second_order, print_to_console=True)

print(sum(Si_code[‘S1’]))

plt.close(‘all’)

plt.figure(“Resultat”)

plt.hist(Y, 500, normed=’True’)

plt.show()

——————————————————————————–