Skip to content

Commit

Permalink
Sample not only from uniform distribution but allow all distributions…
Browse files Browse the repository at this point in the history
… of scipy.stats in morris_sampling, screening/eee, and eee/see.
  • Loading branch information
mcuntz committed Apr 6, 2020
1 parent 35816a4 commit 97686c5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
22 changes: 11 additions & 11 deletions docs/source/userguide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -332,16 +332,16 @@ limits `0` and `1`.

The three parameters :math:`x_0, x_1, x_2` of the Ishigami-Homma
function follow uniform distributions between :math:`-\pi` and
:math:`+\pi`. Say that :math:`x_1` follows a Gaussian
distribution around the mean `0` with a standard deviation of 1.81. We
want to sample between three standard deviations, which includes about
99.7\% of the total distribution. This means that the lower bound
would be 0.0015 and the upper bound 0.9985.
:math:`+\pi`. Say that :math:`x_1` follows a Gaussian distribution
around the mean `0` with a standard deviation of 1.81. We want to
sample between plus or minus three standard deviations, which includes
about 99.7\% of the total distribution. This means that the lower
bound would be 0.0015 (0.003/2.) and the upper bound 0.9985.

.. code-block:: python
import scipy.stats as stats
dist = [None, stats.normal, stats.uniform]
dist = [None, stats.norm, stats.uniform]
distparam = [None, (0., 1.81), (-np.pi, 2.*np.pi)]
lb = [-np.pi, 0.0015, 0.]
ub = [np.pi, 0.9985, 1.]
Expand All @@ -361,16 +361,16 @@ This shows that
:any:`scipy.stats.uniform`, `loc` is the lower limit and
`loc+scale` the upper limit. This means the combination
`dist=None`, `lb=a`, `ub=b` corresponds to
`dist=scipy.stats.uniform`, `distparam=[a,b-a]`, `lb=0`, `ub=1`.
`dist=scipy.stats.uniform`, `distparam=[a,b-a]`, `lb=0`,
`ub=1`.

Note also that

5. if `distparam==None`, `loc=0` and `scale=1` will be taken;
6. `loc` and `scale` are implemented as keywords in
:any:`scipy.stats`. Other parameters such as the shape
parameter of the gamma distribution
:any:`scipy.stats.gamma` must hence be given first,
e.g. `(shape,loc,scale)`.
:any:`scipy.stats`. Other parameters such as for example the shape
parameter of the gamma distribution :any:`scipy.stats.gamma` must
hence be given first, i.e. `(shape,loc,scale)`.

Remember that Morris' method of Elementary Effects assumes uniformly
distributed parameters and that other distributions are an extension
Expand Down
2 changes: 1 addition & 1 deletion pyeee/eee.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def eee(func, *args, **kwargs):
If True, return weighted mean mu*, weighted by sd.
seed : int or array_like
Seed for numpy``s random number generator (default: None).
Seed for numpy's random number generator (default: None).
processes : int, optinal
The number of processes to use to evaluate objective function and constraints (default: 1).
pool : `schwimmbad` pool object, optinal
Expand Down
2 changes: 1 addition & 1 deletion pyeee/morris_method.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
from __future__ import division, absolute_import, print_function
"""
Module provides the Morris Method of Elementary Effects.
Module provides the Morris' Method of Elementary Effects.
It includes optimised sampling of trajectories including optional groups
as well as calculation of the Morris measures mu, stddev and mu*.
Expand Down
7 changes: 3 additions & 4 deletions pyeee/screening.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env python
from __future__ import division, absolute_import, print_function
"""
screening : Provides the function screening/ee for Morris' method
of Elementary Effects.
screening : Provides the function screening/ee for Morris' method of Elementary Effects.
This function was written by Matthias Cuntz while at Institut National
de Recherche en Agriculture, Alimentation et Environnement (INRAE),
Expand Down Expand Up @@ -47,7 +46,7 @@ def screening(func, lb, ub, nt, x0=None, mask=None,
processes=1, pool=None,
verbose=0):
"""
Parameter screening using Morris method of Elementary Effects.
Parameter screening using Morris' method of Elementary Effects.
Note, the input function must be callable as `func(x)`.
Expand Down Expand Up @@ -103,7 +102,7 @@ def screening(func, lb, ub, nt, x0=None, mask=None,
The percent point function ppf is called like this: dist(*distparam).ppf(x)
seed : int or array_like
Seed for numpy``s random number generator (default: None).
Seed for numpy's random number generator (default: None).
processes : int, optional
The number of processes to use to evaluate objective function and constraints (default: 1).
pool : `schwimmbad` pool object, optional
Expand Down
2 changes: 1 addition & 1 deletion pyeee/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* v0.9, Renamed morris.py to morris_method.py and adapted args and kwargs to common names in pyeee, Feb 2020, Matthias Cuntz
* v1.0, Restructured package with functions and utils subpackages, Feb 2020, Matthias Cuntz
* v1.1, Number of final trajectories is argument instead of keyword, Feb 2020, Matthias Cuntz
* v1.2, Sample not only from uniform distribution but allow all distributions of scipy.stats, Mar 2020, Matthias Cuntz
* v1.2, Sample not only from uniform distribution but allow all distributions of scipy.stats, Apr 2020, Matthias Cuntz
.. moduleauthor:: Matthias Cuntz
"""
Expand Down

0 comments on commit 97686c5

Please sign in to comment.