47 if(i >=
firstOrder.size())
throw std::out_of_range(
"Index out of range");
58 if(i >=
totalOrder.size())
throw std::out_of_range(
"Index out of range");
73 if(
secondOrder.size() == 0)
throw std::logic_error(
"Second order Sobol indices were not computed.");
74 if(i >=
firstOrder.size() || j >=
firstOrder.size())
throw std::out_of_range(
"Index out of range");
75 if(i == j)
throw std::invalid_argument(
"Indices must be different for second order Sobol index.");
76 if(i > j) std::swap(i, j);
77 size_t index = i * (2 *
firstOrder.size() - i - 1) / 2 + (j - i - 1);
176 Eigen::MatrixXd
evaluationGrid(
size_t nObs, std::shared_ptr<cmp::grid::Grid> gridType,
bool secondOrder =
false);
208 std::pair<SobolResults, SobolResults>
computeWithBootstrap(
const Eigen::VectorXd &Y,
size_t nBootstrap,
size_t randomSeed = 42);
Performs Global Sensitivity Analysis (GSA) using the Saltelli formulation of Sobol indices.
Definition sobol.h:116
Eigen::VectorXd sliceSaltelliOutput(const Eigen::VectorXd &Y, const Eigen::VectorXs &idx, size_t nObs, size_t dim, bool secondOrder)
Slices the output vector Y from the Sobol evaluation grid to keep only valid or specified indices.
Definition sobol.cpp:42
SobolSaltelli(size_t nObs, size_t dim, bool secondOrder=false)
Constructs a Sobol-Saltelli analyzer with the given configuration.
Definition sobol.h:140
size_t nTotalObs_
The total number of evaluations required across all matrices.
Definition sobol.h:122
size_t nTotalObs() const
Gets the total number of evaluations required based on , , and analysis order.
Definition sobol.h:149
std::pair< SobolResults, SobolResults > computeWithBootstrap(const Eigen::VectorXd &Y, size_t nBootstrap, size_t randomSeed=42)
Computes Sobol indices with bootstrap resampling to estimate statistical confidence intervals.
Definition sobol.cpp:121
size_t dim_
The dimensionality of the input parameter space.
Definition sobol.h:125
SobolSaltelli()=default
Default constructor.
Eigen::MatrixXd evaluationGrid(size_t nObs, std::shared_ptr< cmp::grid::Grid > gridType, bool secondOrder=false)
Constructs the Sobol evaluation grid using the Saltelli sampling scheme.
Definition sobol.cpp:3
bool secondOrder_
Flag indicating whether second-order indices should be computed.
Definition sobol.h:128
size_t dim() const
Gets the number of dimension parameters .
Definition sobol.h:157
size_t nObs() const
Gets the number of base samples .
Definition sobol.h:165
size_t nObs_
The number of base samples .
Definition sobol.h:119
SobolResults compute(const Eigen::VectorXd &Y)
Computes Sobol indices from the output vector Y obtained by evaluating the Saltelli grid.
Definition sobol.cpp:67
Matrix< size_t, Eigen::Dynamic, 1 > VectorXs
Definition cmp_defines.h:20
Header file for statistical functions and classes.
Struct to hold calculated Sobol sensitivity indices.
Definition sobol.h:30
Eigen::VectorXd totalOrder
Vector storing the total-order Sobol indices.
Definition sobol.h:35
double getTotalOrder(size_t i) const
Gets the total-order Sobol index for input parameter .
Definition sobol.h:57
double getSecondOrder(size_t i, size_t j) const
Gets the second-order Sobol index for interaction between parameters and .
Definition sobol.h:72
Eigen::VectorXd firstOrder
Vector storing the first-order (main effect) Sobol indices.
Definition sobol.h:32
Eigen::VectorXd secondOrder
Vector storing the second-order (interaction effect) Sobol indices (if computed).
Definition sobol.h:38
double getFirstOrder(size_t i) const
Gets the first-order Sobol index for input parameter .
Definition sobol.h:46