Skip to content

Commit

Permalink
Update to basics doc
Browse files Browse the repository at this point in the history
  • Loading branch information
David Hadka committed Sep 16, 2015
1 parent f6b7319 commit 4b653fa
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
57 changes: 56 additions & 1 deletion docs/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,63 @@ SALib provides several sensitivity analysis methods, such as Sobol, Morris,
and FAST. There are many factors that determine which method is appropriate
for a specific application, which we will discuss later. However, for now, just
remember that regardless of which method you choose, you need to use only two
functions: :code:`sample` and :code:`analyze`.
functions: :code:`sample` and :code:`analyze`. To demonstrate the use of SALib,
we will walk you through a simple example.

An Example
----------
In this example, we will perform a Sobol' sensitivity analysis of the Ishigami
function, shown below. The Ishigami function is commonly used to test
uncertainty and sensitivity analysis methods because it exhibits strong
nonlinearity and nonmonotonicity.

.. math::
f(x) = sin(x_1) + a sin^2(X_2) + b x_3^4*sin(x_1)
Importing SALib
~~~~~~~~~~~~~~~

The first step is the import the necessary libraries. In SALib, the
:code:`sample` and :code:`analyze` functions are stored in separate
Python modules. For example, below we import the :code:`saltelli` sample
function and the :code:`sobol` analyze function. We also import the Ishigami
function, which is provided as a test function within SALib. Lastly, we
import :code:`numpy`, as it is used by SALib to store the model inputs and
outputs in a matrix.

.. code:: python
from SALib.sample import saltelli
from SALib.analyze import sobol
from SALib.test_functions import Ishigami
import numpy as np
Defining the Model Inputs
~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: python
# Define the model inputs
problem = {
'num_vars': 3,
'names': ['x1', 'x2', 'x3'],
'bounds': [[-3.14159265359, 3.14159265359],
[-3.14159265359, 3.14159265359],
[-3.14159265359, 3.14159265359]]
}
# Generate samples
param_values = saltelli.sample(problem, 1000, calc_second_order=True)
# Run model (example)
Y = Ishigami.evaluate(param_values)
# Perform analysis
Si = sobol.analyze(problem, Y, print_to_console=False)
# Print the first-order sensitivity indices
print Si['S1']
.. autofunction:: SALib.analyze.fast.analyze

2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def __getattr__(cls, name):

# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
add_module_names = False

# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
Expand Down

0 comments on commit 4b653fa

Please sign in to comment.