SALib icon indicating copy to clipboard operation
SALib copied to clipboard

Returning variance instead of sobol index

Open ChitraDangwal opened this issue 3 years ago • 1 comments

If I wanted the variances (the numerator) part in sobol index instead of sobol index is the following change in sobol.py enough?

def first_order(A, AB, B): # First order estimator following Saltelli et al. 2010 CPC, normalized by # sample variance return np.mean(B * (AB - A), axis=0) / ; # np.var(np.r_[A, B], axis=0). (Commenting out the denominator)

def total_order(A, AB, B): # Total order estimator following Saltelli et al. 2010 CPC, normalized by # sample variance return 0.5 * np.mean((A - AB) ** 2, axis=0) / ; # np.var(np.r_[A, B], axis=0) (Commenting out the denominator)

def second_order(A, ABj, ABk, BAj, B): # Second order estimator following Saltelli 2002 Vjk = np.mean(BAj * ABk - A * B, axis=0) / ; # np.var(np.r_[A, B], axis=0) (Commenting out the denominator) Sj = first_order(A, ABj, B) Sk = first_order(A, ABk, B)

return Vjk - Sj - Sk

ChitraDangwal avatar Sep 14 '22 01:09 ChitraDangwal

Hi @ChitraDangwal, yes if you just want the respective variances you just need to not divide by the total variance. Depending on how you are calling the functions, you could simply multiply the output with the total variance that you can calculate manually (or you might know its theoretical value).

tupui avatar Sep 14 '22 14:09 tupui

Closing this issue as your question has been answered.

Thanks for using SALib @ChitraDangwal

ConnectedSystems avatar Sep 24 '22 12:09 ConnectedSystems