SALib / SALib

Sensitivity Analysis Library in Python. Contains Sobol, Morris, FAST, and other methods.
http://SALib.github.io/SALib/
MIT License
868 stars 235 forks source link

sobol with negative result #218

Closed fab6 closed 5 years ago

fab6 commented 5 years ago

Hi,

I have a small test case with negative indices and it is not clear to me, what I am doing wrong (basically the results of a Bungee test case from Saltelli book):

Parameter S1 S1_conf ST ST_conf H_Val -0.137564 inf 1.170733 inf M_Val -0.037697 inf 1.097325 inf sigma_Val -0.024214 inf 0.956763 inf

I attached the data file and the python (called sobol_test1.txt) sobol_test1.txt test file.

post_opt_ea.txt

Do you have an advice? Thank you in advance!

jdherman commented 5 years ago

Hi @fab6 ,

A few things here:

The sobol.analyze function expects the vector Y to be in a specific order, corresponding to the output of that sampling method.

If you don't have the chance to re-run new samples, then you should be looking at the Delta method instead, which is the only method in SALib that works from given data. Example here - https://github.com/SALib/SALib/blob/master/examples/delta/delta.py

Hope this helps.

fab6 commented 5 years ago

Hi,

thank you for the quick help! 1) Ok, I misunderstood the need to have a special sample with sobol. My data were generated with another tool using latin hypercube method to get a uncorrelated data set. I thought this would be enough. Could I use the lhs sample option from salib instead of saltelli for sobol? 2) thank, you, I adapt this.

Thank you!

jdherman commented 5 years ago

No, the LHS method by itself won't work. The Saltelli sampling method is a combination of the Sobol sequence (quasi-random) plus a cross-sampling strategy. In theory you could replace the first step (Sobol sequence) with LHS instead, but the library is not set up to do that right now.

Still, the Sobol sequence is intended to give a uniform distribution with better space-filling properties than a pure random sample. If the model is quick to evaluate, I'd suggest generating a new sample using the saltelli() function as shown in the example.

Ok sounds good, I'll close this for now. Feel free to re-open if you run into more problems.