-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from SURGroup/Development
Development
- Loading branch information
Showing
65 changed files
with
7,010 additions
and
222 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Chatterjee indices | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
These examples serve as a guide for using the Chatterjee sensitivity module. They have been taken from various papers to enable validation of the implementation and have been referenced accordingly. | ||
|
||
1. **Ishigami function** | ||
|
||
In addition to the Pick and Freeze scheme, the Sobol indices can be estimated using the rank statistics approach :cite:`gamboa2020global`. We demonstrate this estimation of the Sobol indices using the Ishigami function. | ||
|
||
2. **Exponential function** | ||
|
||
For the Exponential model, analytical Cramér-von Mises indices are available :cite:`CVM` and since they are equivalent to the Chatterjee indices in the sample limit, they are shown here. | ||
|
||
3. **Sobol function** | ||
|
||
This example was considered in :cite:`gamboa2020global` (page 18) to compare the Pick and Freeze scheme with the rank statistics approach for estimating the Sobol indices. |
76 changes: 76 additions & 0 deletions
76
docs/code/sensitivity/chatterjee/chatterjee_exponential.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
""" | ||
Exponential function | ||
============================================== | ||
The exponential function was used in [1]_ to demonstrate the | ||
Cramér-von Mises indices. Chattererjee indices approach the Cramér-von Mises | ||
indices in the sample limit and will be demonstrated via this example. | ||
.. math:: | ||
f(x) := \exp(x_1 + 2x_2), \quad x_1, x_2 \sim \mathcal{N}(0, 1) | ||
.. [1] Gamboa, F., Klein, T., & Lagnoux, A. (2018). Sensitivity Analysis Based on \ | ||
Cramér-von Mises Distance. SIAM/ASA Journal on Uncertainty Quantification, 6(2), \ | ||
522-548. doi:10.1137/15M1025621. (`Link <https://doi.org/10.1137/15M1025621>`_) | ||
""" | ||
|
||
# %% | ||
from UQpy.run_model.RunModel import RunModel | ||
from UQpy.run_model.model_execution.PythonModel import PythonModel | ||
from UQpy.distributions import Normal | ||
from UQpy.distributions.collection.JointIndependent import JointIndependent | ||
from UQpy.sensitivity.ChatterjeeSensitivity import ChatterjeeSensitivity | ||
from UQpy.sensitivity.PostProcess import * | ||
|
||
np.random.seed(123) | ||
|
||
# %% [markdown] | ||
# **Define the model and input distributions** | ||
|
||
# Create Model object | ||
model = PythonModel( | ||
model_script="local_exponential.py", | ||
model_object_name="evaluate", | ||
var_names=[ | ||
"X_1", | ||
"X_2", | ||
], | ||
delete_files=True, | ||
) | ||
|
||
runmodel_obj = RunModel(model=model) | ||
|
||
# Define distribution object | ||
dist_object = JointIndependent([Normal(0, 1)] * 2) | ||
|
||
# %% [markdown] | ||
# **Compute Chatterjee indices** | ||
|
||
# %% [markdown] | ||
SA = ChatterjeeSensitivity(runmodel_obj, dist_object) | ||
|
||
# Compute Chatterjee indices using the pick and freeze algorithm | ||
SA.run(n_samples=1_000_000) | ||
|
||
# %% [markdown] | ||
# **Chattererjee indices** | ||
# | ||
# Chattererjee indices approach the Cramér-von Mises indices in the sample limit. | ||
# | ||
# Expected value of the sensitivity indices: | ||
# | ||
# :math:`S^1_{CVM} = \frac{6}{\pi} \operatorname{arctan}(2) - 2 \approx 0.1145` | ||
# | ||
# :math:`S^2_{CVM} = \frac{6}{\pi} \operatorname{arctan}(\sqrt{19}) - 2 \approx 0.5693` | ||
|
||
# %% | ||
SA.first_order_chatterjee_indices | ||
|
||
# **Plot the Chatterjee indices** | ||
fig1, ax1 = plot_sensitivity_index( | ||
SA.first_order_chatterjee_indices[:, 0], | ||
plot_title="Chatterjee indices", | ||
color="C2", | ||
) |
Oops, something went wrong.