Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Morris method normal distribution sample #345

Open
MatthiVH opened this issue Sep 10, 2020 · 4 comments
Open

Morris method normal distribution sample #345

MatthiVH opened this issue Sep 10, 2020 · 4 comments

Comments

@MatthiVH
Copy link

MatthiVH commented Sep 10, 2020

Hi,

I was wondering how to create a sample with a normal distribution using the Morris sampler.
Since 'dists' is not yet supported in the morris sampler, I tried a workaround (tested with the saltelli-sampler that has 'dists' and it worked), but I receive lots of infinite-values in the sample with the morris method when converting uniform to normal distributions. Is there a solution for this?

Tried code:

from SALib.sample import morris

import pandas as pd

import scipy.stats.distributions as ssd

import lhsmdu



# problem definition ('num_vars', 'names', 'bounds', 'dists')

prob_dists_code = {'num_vars': 3,
                      
                      'names': ['P1', 'P2', 'P3'],

                     'groups': None,

                     'bounds': [[0.0, 1.0], [0.0, 1.0], [0.0, 1.0]]}

np_array = morris.sample(prob_dists_code, N=1000, num_levels=4, optimal_trajectories=None)

p1 = ssd.uniform(loc=0.9, scale=0.2)
p2 = ssd.norm(loc=45, scale=10)
p3 = ssd.norm(loc=0, scale=1)

new_samples = np_array

new_samples[:, 0] = lhsmdu.inverseTransformSample(p1, np_array[:, 0])

new_samples[:, 1] = lhsmdu.inverseTransformSample(p2, np_array[:, 1])

new_samples[:, 2] = lhsmdu.inverseTransformSample(p3, np_array[:, 2])


df = pd.DataFrame(new_samples)

df.columns = ['P1', 'P2', 'P3']

print(df)

Kind regards,
Matthias

@ConnectedSystems
Copy link
Member

Hi @MatthiVH

Could you try the most recent development release and let me know if this is still an issue?

Recommend doing so in a fresh conda or virtual environment

Install with:

pip install --pre salib

@MatthiVH
Copy link
Author

Hi,
Yes, I'll report back by the beginning of next week.
Kind regards,
Matthias

@MatthiVH
Copy link
Author

Hi @ConnectedSystems,

Yes it is still an issue with the latest release. The 'dists'-statement is not recognized in the 'problem' and if I want to post-process the uniform samples towards the distribution I want, lots of infinity values show up (which does happen when using sobol, fast, ...

Kind regards,
Matthias

@ConnectedSystems
Copy link
Member

ConnectedSystems commented Oct 24, 2020

Hi again,

Looking into this deeper, the Morris method does not, as originally conceived, support alternate distributions. The trajectory sampling employed assumes an uniform distribution of the input space, and scaling the sampled points to other distributions don't always make sense (as you have encountered).

There are improvements to Morris to allow its use with alternate input distributions (see for example, [1]), but we currently have no plan in the short-term to implement this.

[1] Feng, K., Lu, Z., Yang, C., 2019. Enhanced Morris method for global sensitivity analysis: good proxy of Sobol’ index. Struct Multidisc Optim 59, 373–387. https://doi.org/10.1007/s00158-018-2071-7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants