Skip to content

Commit

Permalink
Fixes failing examples due to changed naming conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
dimtsap committed Aug 10, 2022
1 parent 0b0ee2f commit 7f3a9dc
Show file tree
Hide file tree
Showing 15 changed files with 125 additions and 149 deletions.
24 changes: 12 additions & 12 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,18 @@ jobs:
displayName: Install Anaconda packages
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
- bash: |
source activate myEnvironment
conda build . recipe --variants "{'version': ['$(GitVersion.SemVer)']}"
displayName: Build Noarch conda packages
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
- bash: |
source activate myEnvironment
anaconda login --username $(ANACONDAUSER) --password $(ANACONDAPW)
anaconda upload /usr/local/miniconda/envs/myEnvironment/conda-bld/noarch/*.tar.bz2
displayName: Upload conda packages
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
# - bash: |
# source activate myEnvironment
# conda build . recipe --variants "{'version': ['$(GitVersion.SemVer)']}"
# displayName: Build Noarch conda packages
# condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
#
# - bash: |
# source activate myEnvironment
# anaconda login --username $(ANACONDAUSER) --password $(ANACONDAPW)
# anaconda upload /usr/local/miniconda/envs/myEnvironment/conda-bld/noarch/*.tar.bz2
# displayName: Upload conda packages
# condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')

- job: "Create_Docker_images"
dependsOn: Build_UQpy_and_run_tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
SA = ChatterjeeSensitivity(runmodel_obj, dist_object)

# Compute Chatterjee indices using the pick and freeze algorithm
computed_indices = SA.run(n_samples=1_000_000)
SA.run(n_samples=1_000_000)

# %% [markdown]
# **Chattererjee indices**
Expand All @@ -66,11 +66,11 @@
# :math:`S^2_{CVM} = \frac{6}{\pi} \operatorname{arctan}(\sqrt{19}) - 2 \approx 0.5693`

# %%
computed_indices["chatterjee_i"]
SA.first_order_chatterjee_indices

# **Plot the Chatterjee indices**
fig1, ax1 = plot_sensitivity_index(
computed_indices["chatterjee_i"][:, 0],
SA.first_order_chatterjee_indices[:, 0],
plot_title="Chatterjee indices",
color="C2",
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
==============================================
The ishigami function is a non-linear, non-monotonic function that is commonly used to
benchmark uncertainty and senstivity analysis methods.
benchmark uncertainty and sensitivity analysis methods.
.. math::
f(x_1, x_2, x_3) = sin(x_1) + a \cdot sin^2(x_2) + b \cdot x_3^4 sin(x_1)
Expand Down Expand Up @@ -49,7 +49,7 @@
# %% [markdown]
SA = ChatterjeeSensitivity(runmodel_obj, dist_object)

computed_indices = SA.run(
SA.run(
n_samples=100_000,
estimate_sobol_indices=True,
n_bootstrap_samples=100,
Expand All @@ -60,18 +60,18 @@
# **Chattererjee indices**

# %%
computed_indices["chatterjee_i"]
SA.first_order_chatterjee_indices

# %% [markdown]
# **Confidence intervals for the Chatterjee indices**

# %%
computed_indices["confidence_interval_chatterjee_i"]
SA.confidence_interval_chatterjee

# **Plot the Chatterjee indices**
fig1, ax1 = plot_sensitivity_index(
computed_indices["chatterjee_i"][:, 0],
computed_indices["confidence_interval_chatterjee_i"],
SA.first_order_chatterjee_indices[:, 0],
SA.confidence_interval_chatterjee,
plot_title="Chatterjee indices",
color="C2",
)
Expand All @@ -88,11 +88,11 @@
# :math:`S_3`: 0.0

# %%
computed_indices["sobol_i"]
SA.first_order_sobol_indices

# **Plot the first order Sobol indices**
fig2, ax2 = plot_sensitivity_index(
computed_indices["sobol_i"][:, 0],
SA.first_order_sobol_indices[:, 0],
plot_title="First order Sobol indices",
color="C0",
)
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,17 @@
SA = ChatterjeeSensitivity(runmodel_obj, dist_object)

# Compute Chatterjee indices using rank statistics
computed_indices = SA.run(n_samples=500_000, estimate_sobol_indices=True)
SA.run(n_samples=500_000, estimate_sobol_indices=True)

# %% [markdown]
# **Chatterjee indices**

# %%
computed_indices["chatterjee_i"]
SA.first_order_chatterjee_indices

# **Plot the Chatterjee indices**
fig1, ax1 = plot_sensitivity_index(
computed_indices["chatterjee_i"][:, 0],
SA.first_order_chatterjee_indices[:, 0],
plot_title="Chatterjee indices",
color="C2",
)
Expand All @@ -101,11 +101,11 @@
# :math:`S_6` = 0.03760626

# %%
computed_indices["sobol_i"]
SA.first_order_sobol_indices

# **Plot the first order Sobol indices**
fig2, ax2 = plot_sensitivity_index(
computed_indices["sobol_i"][:, 0],
SA.first_order_sobol_indices[:, 0],
plot_title="First order Sobol indices",
color="C0",
)
Expand Down Expand Up @@ -143,12 +143,12 @@
for i, sample_size in enumerate(sample_sizes):

# Estimate using rank statistics
_indices = SA_chatterjee.run(n_samples=sample_size*7, estimate_sobol_indices=True)
store_rank_stats[:, i] = _indices["sobol_i"].ravel()
SA_chatterjee.run(n_samples=sample_size*7, estimate_sobol_indices=True)
store_rank_stats[:, i] = SA_chatterjee.first_order_sobol_indices.ravel()

# Estimate using Pick and Freeze approach
_indices = SA_sobol.run(n_samples=sample_size)
store_pick_freeze[:, i] = _indices["sobol_i"].ravel()
SA_sobol.run(n_samples=sample_size)
store_pick_freeze[:, i] = SA_sobol.first_order_indices.ravel()

# %%

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
# %% [markdown]
SA_sobol = SobolSensitivity(runmodel_obj, dist_object)

computed_indices_sobol = SA_sobol.run(n_samples=50_000)
SA_sobol.run(n_samples=50_000)

# %% [markdown]
# **First order Sobol indices**
Expand All @@ -76,27 +76,27 @@
# :math:`\mathrm{S}_2 = \frac{b^2 \cdot \mathbb{V}[X_2]}{a^2 \cdot \mathbb{V}[X_1] + b^2 \cdot \mathbb{V}[X_2]} = \frac{2^2 \cdot 1}{1^2 \cdot 1 + 2^2 \cdot 1} = 0.8`

# %%
computed_indices_sobol["sobol_i"]
SA_sobol.first_order_indices

# %% [markdown]
# **Compute Chatterjee indices**

# %% [markdown]
SA_chatterjee = ChatterjeeSensitivity(runmodel_obj, dist_object)

computed_indices_chatterjee = SA_chatterjee.run(n_samples=50_000)
SA_chatterjee.run(n_samples=50_000)

# %%
computed_indices_chatterjee["chatterjee_i"]
SA_chatterjee.first_order_chatterjee_indices

# %%
SA_cvm = cvm(runmodel_obj, dist_object)

# Compute CVM indices using the pick and freeze algorithm
computed_indices_cvm = SA_cvm.run(n_samples=20_000, estimate_sobol_indices=True)
SA_cvm.run(n_samples=20_000, estimate_sobol_indices=True)

# %%
computed_indices_cvm["CVM_i"]
SA_cvm.first_order_CramerVonMises_indices

# %%
# **Plot all indices**
Expand All @@ -106,9 +106,9 @@
variable_names = [r"$X_{}$".format(i + 1) for i in range(num_vars)]

# round to 2 decimal places
indices_1 = np.around(computed_indices_sobol["sobol_i"][:, 0], decimals=2)
indices_2 = np.around(computed_indices_chatterjee["chatterjee_i"][:, 0], decimals=2)
indices_3 = np.around(computed_indices_cvm["CVM_i"][:, 0], decimals=2)
indices_1 = np.around(SA_sobol.first_order_indices[:, 0], decimals=2)
indices_2 = np.around(SA_chatterjee.first_order_chatterjee_indices[:, 0], decimals=2)
indices_3 = np.around(SA_cvm.first_order_CramerVonMises_indices[:, 0], decimals=2)

fig, ax = plt.subplots()
width = 0.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
# %%
SA_sobol = SobolSensitivity(runmodel_obj, dist_object)

computed_indices_sobol = SA_sobol.run(n_samples=100_000)
SA_sobol.run(n_samples=100_000)

# %% [markdown]
# **First order Sobol indices**
Expand All @@ -66,7 +66,7 @@
# :math:`S_3` = 0.0

# %%
computed_indices_sobol["sobol_i"]
SA_sobol.first_order_indices

# %% [markdown]
# **Total order Sobol indices**
Expand All @@ -80,28 +80,28 @@
# :math:`S_{T_3}` = 0.24368366

# %%
computed_indices_sobol["sobol_total_i"]
SA_sobol.total_order_indices

# %% [markdown]
# **Compute Chatterjee indices**

# %% [markdown]
SA_chatterjee = ChatterjeeSensitivity(runmodel_obj, dist_object)

computed_indices_chatterjee = SA_chatterjee.run(n_samples=50_000)
SA_chatterjee.run(n_samples=50_000)

# %%
computed_indices_chatterjee["chatterjee_i"]
SA_chatterjee.first_order_chatterjee_indices

# %% [markdown]
# **Compute Cramér-von Mises indices**
SA_cvm = cvm(runmodel_obj, dist_object)

# Compute CVM indices using the pick and freeze algorithm
computed_indices_cvm = SA_cvm.run(n_samples=20_000, estimate_sobol_indices=True)
SA_cvm.run(n_samples=20_000, estimate_sobol_indices=True)

# %%
computed_indices_cvm["CVM_i"]
SA_cvm.first_order_CramerVonMises_indices

# %%
# **Plot all indices**
Expand All @@ -111,9 +111,9 @@
variable_names = [r"$X_{}$".format(i + 1) for i in range(num_vars)]

# round to 2 decimal places
indices_1 = np.around(computed_indices_sobol["sobol_i"][:, 0], decimals=2)
indices_2 = np.around(computed_indices_chatterjee["chatterjee_i"][:, 0], decimals=2)
indices_3 = np.around(computed_indices_cvm["CVM_i"][:, 0], decimals=2)
indices_1 = np.around(SA_sobol.first_order_indices[:, 0], decimals=2)
indices_2 = np.around(SA_chatterjee.first_order_chatterjee_indices[:, 0], decimals=2)
indices_3 = np.around(SA_cvm.first_order_CramerVonMises_indices[:, 0], decimals=2)

fig, ax = plt.subplots()
width = 0.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
SA = cvm(runmodel_obj, dist_object)

# Compute CVM indices using the pick and freeze algorithm
computed_indices = SA.run(n_samples=20_000, estimate_sobol_indices=True)
SA.run(n_samples=20_000, estimate_sobol_indices=True)

# %% [markdown]
# **Cramér-von Mises indices**
Expand All @@ -60,11 +60,11 @@
# :math:`S^2_{CVM} = \frac{6}{\pi} \operatorname{arctan}(\sqrt{19}) - 2 \approx 0.5693`

# %%
computed_indices["CVM_i"]
SA.first_order_CramerVonMises_indices

# **Plot the CVM indices**
fig1, ax1 = plot_sensitivity_index(
computed_indices["CVM_i"][:, 0],
SA.first_order_CramerVonMises_indices[:, 0],
plot_title="Cramér-von Mises indices",
color="C4",
)
Expand All @@ -79,11 +79,11 @@
# :math:`S_2` = 0.3738

# %%
computed_indices["sobol_i"]
SA.first_order_sobol_indices

# **Plot the first order Sobol indices**
fig2, ax2 = plot_sensitivity_index(
computed_indices["sobol_i"][:, 0],
SA.first_order_sobol_indices[:, 0],
plot_title="First order Sobol indices",
color="C0",
)
Expand All @@ -92,12 +92,12 @@
# **Estimated total order Sobol indices**

# %%
computed_indices["sobol_total_i"]
SA.total_order_sobol_indices

# **Plot the first and total order sensitivity indices**
fig3, ax3 = plot_index_comparison(
computed_indices["sobol_i"][:, 0],
computed_indices["sobol_total_i"][:, 0],
SA.first_order_sobol_indices[:, 0],
SA.total_order_sobol_indices[:, 0],
label_1="First order Sobol indices",
label_2="Total order Sobol indices",
plot_title="First and Total order Sobol indices",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@
SA = cvm(runmodel_obj, dist_object)

# Compute Sobol indices using rank statistics
computed_indices = SA.run(n_samples=50_000, estimate_sobol_indices=True)
SA.run(n_samples=50_000, estimate_sobol_indices=True)

# %% [markdown]
# **Cramér-von Mises indices**

# %%
computed_indices["CVM_i"]
SA.first_order_CramerVonMises_indices

# **Plot the CVM indices**
fig1, ax1 = plot_sensitivity_index(
computed_indices["CVM_i"][:, 0],
SA.first_order_CramerVonMises_indices[:, 0],
plot_title="Cramér-von Mises indices",
color="C4",
)
Expand All @@ -95,11 +95,11 @@
# :math:`S_6` = 0.03760626

# %%
computed_indices["sobol_i"]
SA.total_order_sobol_indices

# **Plot the first order Sobol indices**
fig2, ax2 = plot_sensitivity_index(
computed_indices["sobol_i"][:, 0],
SA.total_order_sobol_indices[:, 0],
plot_title="First order Sobol indices",
color="C0",
)
Loading

0 comments on commit 7f3a9dc

Please sign in to comment.