Skip to content

Commit

Permalink
Changed variable name: CI -> confidence interval
Browse files Browse the repository at this point in the history
  • Loading branch information
Prateek Bhustali committed May 23, 2022
1 parent e0ad8da commit d78b28b
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 33 deletions.
10 changes: 6 additions & 4 deletions src/UQpy/sensitivity/Chatterjee.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(self, runmodel_object, dist_object, random_state=None, **kwargs):
self.sobol_i = None
"Sobol indices computed using the rank statistics, :class:`numpy.ndarray` of shape :code:`(num_vars, 1)`"

self.CI_chatterjee_i = None
self.confidence_interval_chatterjee_i = None
"Confidence intervals for the Chatterjee sensitivity indices, :class:`numpy.ndarray` of shape :code:`(num_vars, 2)`"

self.num_vars = None
Expand Down Expand Up @@ -115,7 +115,7 @@ def run(
:return: A :class:`dict` with the following keys: \
:code:`'chatterjee_i'` of shape :code:`(num_vars, 1)`, \
:code:`'CI_chatterjee_i'` of shape :code:`(num_vars, 2)`, \
:code:`'confidence_interval_chatterjee_i'` of shape :code:`(num_vars, 2)`, \
:code:`'sobol_i'` of shape :code:`(num_vars, 1)`.
"""
Expand Down Expand Up @@ -185,7 +185,7 @@ def run(

estimator_inputs = [A_samples, A_model_evals]

self.CI_chatterjee_i = self.bootstrapping(
self.confidence_interval_chatterjee_i = self.bootstrapping(
self.compute_chatterjee_indices,
estimator_inputs,
computed_indices["chatterjee_i"],
Expand All @@ -197,7 +197,9 @@ def run(
"UQpy: Confidence intervals for Chatterjee indices computed successfully.\n"
)

computed_indices["CI_chatterjee_i"] = self.CI_chatterjee_i
computed_indices[
"confidence_interval_chatterjee_i"
] = self.confidence_interval_chatterjee_i

return computed_indices

Expand Down
10 changes: 6 additions & 4 deletions src/UQpy/sensitivity/CramervonMises.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(
self.CVM_i = None
"First order Cramér-von Mises indices, :class:`numpy.ndarray` of shape :code:`(num_vars, 1)`"

self.CI_CVM_i = None
self.confidence_interval_CVM_i = None
"Confidence intervals of the first order Cramér-von Mises indices, :class:`numpy.ndarray` of shape :code:`(num_vars, 2)`"

self.sobol_i = None
Expand Down Expand Up @@ -124,7 +124,7 @@ def run(
:return: A :class:`dict` with the following keys: \
:code:`CVM_i` of shape :code:`(num_vars, 1)`, \
:code:`CI_CVM_i` of shape :code:`(num_vars, 2)`, \
:code:`confidence_interval_CVM_i` of shape :code:`(num_vars, 2)`, \
:code:`sobol_i` of shape :code:`(num_vars, 1)`, \
:code:`sobol_total_i` of shape :code:`(num_vars, 1)`.
Expand Down Expand Up @@ -205,7 +205,7 @@ def run(
C_i_model_evals,
]

self.CI_CVM_i = self.bootstrapping(
self.confidence_interval_CVM_i = self.bootstrapping(
self.pick_and_freeze_estimator,
estimator_inputs,
computed_indices["CVM_i"],
Expand All @@ -218,7 +218,9 @@ def run(
)

# Store the indices in the dictionary
computed_indices["CI_CVM_i"] = self.CI_CVM_i
computed_indices[
"confidence_interval_CVM_i"
] = self.confidence_interval_CVM_i

################## COMPUTE SOBOL INDICES ##################

Expand Down
16 changes: 10 additions & 6 deletions src/UQpy/sensitivity/GeneralisedSobol.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ def run(
:return: A :class:`dict` with the following keys: \
:code:`gen_sobol_i` of shape :code:`(num_vars, 1)`, \
:code:`gen_sobol_total_i` of shape :code:`(num_vars, 1)`, \
:code:`CI_gen_sobol_i` of shape :code:`(num_vars, 2)`, \
:code:`CI_gen_sobol_total_i` of shape :code:`(num_vars, 2)`.
:code:`confidence_interval_gen_sobol_i` of shape :code:`(num_vars, 2)`, \
:code:`confidence_interval_gen_sobol_total_i` of shape :code:`(num_vars, 2)`.
"""

Expand Down Expand Up @@ -225,7 +225,7 @@ def run(
]

# First order generalised Sobol indices
self.CI_gen_sobol_i = self.bootstrapping(
self.confidence_interval_gen_sobol_i = self.bootstrapping(
self.compute_first_order_generalised_sobol_indices,
estimator_inputs,
computed_indices["gen_sobol_i"],
Expand All @@ -238,7 +238,7 @@ def run(
)

# Total order generalised Sobol indices
self.CI_gen_sobol_total_i = self.bootstrapping(
self.confidence_interval_gen_sobol_total_i = self.bootstrapping(
self.compute_total_order_generalised_sobol_indices,
estimator_inputs,
computed_indices["gen_sobol_total_i"],
Expand All @@ -251,8 +251,12 @@ def run(
)

# Store the indices in the dictionary
computed_indices["CI_gen_sobol_i"] = self.CI_gen_sobol_i
computed_indices["CI_gen_sobol_total_i"] = self.CI_gen_sobol_total_i
computed_indices[
"confidence_interval_gen_sobol_i"
] = self.confidence_interval_gen_sobol_i
computed_indices[
"confidence_interval_gen_sobol_total_i"
] = self.confidence_interval_gen_sobol_total_i

return computed_indices

Expand Down
30 changes: 18 additions & 12 deletions src/UQpy/sensitivity/Sobol.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ def __init__(
self.sobol_ij = None
"Second order Sobol indices, :class:`numpy.ndarray` of shape `(num_second_order_terms, n_outputs)`"

self.CI_sobol_i = None
self.confidence_interval_sobol_i = None
"Confidence intervals for the first order Sobol indices, :class:`numpy.ndarray` of shape `(num_vars, 2)`"

self.CI_sobol_total_i = None
self.confidence_interval_sobol_total_i = None
"Confidence intervals for the total order Sobol indices, :class:`numpy.ndarray` of shape `(num_vars, 2)`"

self.CI_sobol_ij = None
self.confidence_interval_sobol_ij = None
"Confidence intervals for the second order Sobol indices, :class:`numpy.ndarray` of shape `(num_second_order_terms, 2)`"

self.n_samples = None
Expand Down Expand Up @@ -176,11 +176,11 @@ def run(
:code:`sobol_i` of shape :code:`(num_vars, 1)`, \
:code:`sobol_total_i` of shape :code:`(num_vars, 1)`, \
:code:`sobol_ij` of shape :code:`(num_second_order_terms, 1)`, \
:code:`CI_sobol_i` of shape :code:`(num_vars, 2)`, \
:code:`confidence_interval_sobol_i` of shape :code:`(num_vars, 2)`, \
if multioutput: Shape: `(n_outputs, num_vars, 2)`, \
:code:`CI_sobol_total_i` of shape :code:`(num_vars, 2)`, \
:code:`confidence_interval_sobol_total_i` of shape :code:`(num_vars, 2)`, \
if multioutput: Shape: `(n_outputs, num_vars, 2)`, \
:code:`CI_sobol_ij` of shape :code:`(num_second_order_terms, 2)`
:code:`confidence_interval_sobol_ij` of shape :code:`(num_second_order_terms, 2)`
if multioutput: Shape: `(n_outputs, num_second_order_terms, 2)`, \
"""
Expand Down Expand Up @@ -321,7 +321,7 @@ def run(
]

# First order Sobol indices
self.CI_sobol_i = self.bootstrapping(
self.confidence_interval_sobol_i = self.bootstrapping(
compute_first_order,
estimator_inputs,
computed_indices["sobol_i"],
Expand All @@ -334,10 +334,12 @@ def run(
"UQpy: Confidence intervals for First order Sobol indices computed successfully."
)

computed_indices["CI_sobol_i"] = self.CI_sobol_i
computed_indices[
"confidence_interval_sobol_i"
] = self.confidence_interval_sobol_i

# Total order Sobol indices
self.CI_sobol_total_i = self.bootstrapping(
self.confidence_interval_sobol_total_i = self.bootstrapping(
compute_total_order,
estimator_inputs,
computed_indices["sobol_total_i"],
Expand All @@ -350,11 +352,13 @@ def run(
"UQpy: Confidence intervals for Total order Sobol indices computed successfully."
)

computed_indices["CI_sobol_total_i"] = self.CI_sobol_total_i
computed_indices[
"confidence_interval_sobol_total_i"
] = self.confidence_interval_sobol_total_i

# Second order Sobol indices
if estimate_second_order:
self.CI_sobol_ij = self.bootstrapping(
self.confidence_interval_sobol_ij = self.bootstrapping(
compute_second_order,
estimator_inputs,
computed_indices["sobol_ij"],
Expand All @@ -368,7 +372,9 @@ def run(
"UQpy: Confidence intervals for Second order Sobol indices computed successfully."
)

computed_indices["CI_sobol_ij"] = self.CI_sobol_ij
computed_indices[
"confidence_interval_sobol_ij"
] = self.confidence_interval_sobol_ij

return computed_indices

Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/sensitivity/test_cramer_von_mises.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def bootstrap_CVM_index_variance(CVM_object, NUM_SAMPLES):
)

First_order = computed_indices["CVM_i"].ravel()
upper_bound_first_order = computed_indices["CI_CVM_i"][:, 1]
upper_bound_first_order = computed_indices["confidence_interval_CVM_i"][:, 1]

#### Compute variance ####
std_bootstrap_first_order = (upper_bound_first_order - First_order) / delta
Expand Down
6 changes: 4 additions & 2 deletions tests/unit_tests/sensitivity/test_generalised_sobol.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,10 @@ def bootstrap_generalised_sobol_index_variance(

gen_sobol_i = computed_indices["gen_sobol_i"].ravel()
gen_sobol_total_i = computed_indices["gen_sobol_total_i"].ravel()
upper_bound_first_order = computed_indices["CI_gen_sobol_i"][:, 1]
upper_bound_total_order = computed_indices["CI_gen_sobol_total_i"][:, 1]
upper_bound_first_order = computed_indices["confidence_interval_gen_sobol_i"][:, 1]
upper_bound_total_order = computed_indices["confidence_interval_gen_sobol_total_i"][
:, 1
]

std_bootstrap_first_order = (upper_bound_first_order - gen_sobol_i) / delta
std_bootstrap_total_order = (upper_bound_total_order - gen_sobol_total_i) / delta
Expand Down
10 changes: 6 additions & 4 deletions tests/unit_tests/sensitivity/test_sobol.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,14 @@ def bootstrap_sobol_index_variance(sobol_object, NUM_SAMPLES):

First_order = computed_indices["sobol_i"].ravel()
Total_order = computed_indices["sobol_total_i"].ravel()
CI_first_order = computed_indices["CI_sobol_i"]
CI_total_order = computed_indices["CI_sobol_total_i"]
confidence_interval_first_order = computed_indices["confidence_interval_sobol_i"]
confidence_interval_total_order = computed_indices[
"confidence_interval_sobol_total_i"
]

#### Compute variance ####
upper_bound_first_order = CI_first_order[:, 1]
upper_bound_total_order = CI_total_order[:, 1]
upper_bound_first_order = confidence_interval_first_order[:, 1]
upper_bound_total_order = confidence_interval_total_order[:, 1]

std_bootstrap_first_order = (upper_bound_first_order - First_order) / delta
std_bootstrap_total_order = (upper_bound_total_order - Total_order) / delta
Expand Down

0 comments on commit d78b28b

Please sign in to comment.