This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Sobol' as a numpy.random.Generator. | |
.. note:: This script relies SciPy >1.7 | |
--------------------------- | |
MIT License | |
Copyright (c) 2021 Pamphile Tupui ROY |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Sampling a joint distribution with a copula. | |
A copula describes the dependency between the marginal | |
distributions. Using the copula, you can sample from a | |
joint distribution. | |
--------------------------- | |
MIT License |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Benford's law to measure random number generation quality. | |
.. note:: This script relies on a modified version of scipy. Pull Request: | |
https://github.com/scipy/scipy/pull/10844 | |
--------------------------- | |
MIT License | |
Copyright (c) 2020 Pamphile Tupui ROY |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Integration convergence using Halton sequence: scrambling effect. | |
Compute the convergence rate for integrating functions using Halton low | |
discrepancy sequence [1]_. We are interested in the effect of scrambling [2]_. | |
Two sets of functions are considered: | |
(i) The first set of functions are synthetic examples specifically designed | |
to verify the correctness of the implementation [4]_. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Integration convergence using Sobol' sequence: removing the first point. | |
Compute the convergence rate for integrating functions using Sobol' low | |
discrepancy sequence [1]_. We are interested in measuring the effect of | |
removing the first point of the sequence ([0, ...]). | |
Two sets of functions are considered: | |
(i) The first set of functions are synthetic examples specifically designed | |
to verify the correctness of the implementation [3]_. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import lru_cache | |
import numpy as np | |
import copy | |
import openturns as ot | |
from statsmodels.tools import sequences | |
dim = 2 | |
n_samples = 20 | |
doe_init = np.array(ot.SobolSequence(dim).generate(n_samples)) | |
disc_init = sequences.discrepancy(doe_init) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r"""Visual explanation of Moment independent sensitivity analysis. | |
Moment-based method are based on the whole PDF to mitigate these | |
issues (Borgonovo2007). Based on the unconditional PDF, a conditional PDF per | |
parameter is computed. The more the conditional PDF deviates from the | |
unconditional PDF, the more the parameter has an impact on the quantity of | |
interest. The same procedure can be done using the Empirical Cumulative | |
Density Function (ECDF), respectively with the unconditional ECDF. | |
This visually shows this procedure. Bins of samples (red circles) are used to | |
compute a conditional PDF of the output. This PDF is compared to the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r"""Visual explanation of Sobol' indices. | |
Sobol' indices are metrics to express sensitivity of the output from | |
perturbations comming from input parameters. First order indices write | |
.. math:: S_{x_i} = \frac{\mathbb{V}_i(Y)}{\mathbb{V}[Y]} = | |
\frac{\mathbb{\mathbb{V}}[\mathbb{E}(Y|x_i)]}{\mathbb{V}[Y]} | |
The following is using the Ishigami function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Cosine transformation sensitivity indices. | |
Using a Discrete Cosine Transformation (DCT), it is possible to compute | |
first order sensitivity indices. | |
Reference: | |
Plischke E., How to compute variance-based sensitivity indicators with your | |
spreadsheet software, Environmental Modelling & Software, | |
2012. DOI: 10.1016/j.envsoft.2012.03.004 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Minimum Spanning Tree. | |
MST is used here as a discrepancy criterion. | |
Comparing two different designs: the higher the mean, the better the design is | |
in terms of space filling. | |
--------------------------- | |
MIT License |