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

Allow to give Distributions for param_range #99

Closed
scheidan opened this issue Feb 20, 2023 · 7 comments · Fixed by #133
Closed

Allow to give Distributions for param_range #99

scheidan opened this issue Feb 20, 2023 · 7 comments · Fixed by #133

Comments

@scheidan
Copy link
Contributor

Sometimes it is convenient to provide a distribution instead of an uniform input range. See e.g. this example from GlobalSensitivityAnalysis.jl:

# define the data
data = SobolData(
    params = OrderedDict(:x1 => Uniform(-3.14159265359, 3.14159265359),
        :x2 => Uniform(-3.14159265359, 3.14159265359),
        :x3 => Uniform(-3.14159265359, 3.14159265359)),
    N = 1000
)

# generate samples using Sobol sequence
samples = sample(data)
# run model (example)
Y = ishigami(samples)
# perform Sobol Analysis
analyze(data, Y)

In particular, see https://github.com/lrennels/GlobalSensitivityAnalysis.jl/blob/01da54f81407120d2c91f28f6637ddffa350f146/src/utils.jl#L45 how map the distributions to samples with the quantile function.

@AlexNascou
Copy link

I second this suggestion. It would be great if the input parameters could be sampled from a distribution rather than simply from a range. For example, I'm using the eFAST method and I'd like to be able to choose a normal distribution with a specified mean and variance for some of my input parameters.

@Vaibhavdixit02
Copy link
Member

This makes sense but I would appreciate if you have some reference of how the sampling should be done from that for it to be space-filling.

Meanwhile you could already do the sampling on your end and pass in the design matrix https://docs.sciml.ai/GlobalSensitivity/stable/tutorials/parallelized_gsa/#Direct-Use-of-Design-Matrices

@Vaibhavdixit02
Copy link
Member

Actually, it won't work for eFAST but work for Sobol. eFAST is defined by its unique sampling as described here https://docs.sciml.ai/GlobalSensitivity/stable/methods/efast/. I don't think it can be used for non-uniform distribution, but I might be wrong so would be interested to see if it has been done somewhere.

Also note that there are some methods that require a distribution, and hence might be better suited for you so take a look at those in docs

@AlexNascou
Copy link

There appears to be Matlab package made at the University of Michigan which accepts distributions for the input parameters. Here is their website with their scripts: http://malthus.micro.med.umich.edu/lab/usadata/. (see parameterdist.m file).

I've seen distributions used for input parameters for eFAST in a few places in the literature, for example https://www.sciencedirect.com/science/article/pii/S0304380021002088 (see tables in appendices) but they don't give any details on how they implemented it. And Saltelli's original paper on eFAST suggests the use of input parameter pdfs (see Table 6) https://scholar.google.com/citations?view_op=view_citation&hl=en&user=vqhLsGkAAAAJ&citation_for_view=vqhLsGkAAAAJ:9yKSN-GCB0IC.

The math here is above my head, so I'm not sure how difficult this would be to implement, or if these sources are useful to you, but I appreciate you spending the time to take a look at this. Thanks!

@Vaibhavdixit02
Copy link
Member

Thanks for sharing the references, I'll take a look!

@scheidan
Copy link
Contributor Author

scheidan commented Nov 6, 2023

Comparing the implementation of GlobalSensitivityAnalysis.jl and the Matlab implementation linked above I think all that is needed is a change on this line:

ps[j, l] .= quantile.(Uniform(p_range[j][1], p_range[j][2]),

So instead of constructing a Uniform distribution, we could use any user provided (univariate) distribution here.

@Vaibhavdixit02
Copy link
Member

That makes sense, sorry I haven't had time to look into this on my end. Do you want to do a PR to make that change? There can be a kwarg dist_params defaulting to uniform distributions that takes an array of distributions

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

Successfully merging a pull request may close this issue.

3 participants