global sensitivity analysis in matlab

To perform global sensitivity analysis in Matlab, one can use the Sobol Method, which is a variance-based method. Here are the general steps to follow:

  1. Select the input parameters and their respective probability distributions.
  2. Define the model, which takes the input parameters as inputs and outputs the response variable(s).
  3. Generate a set of input parameter samples using a Latin Hypercube Sampling (LHS) design.
  4. Compute the output of the model for each sample.
  5. Compute the sensitivity indices using the Sobol method.

Here is an example implementation:

main.m
% Define the input parameters and their respective probability distributions
distributions = {'normal', 'uniform', 'beta'};
parameters = {'param1', 'param2', 'param3'};
paramspec = [{1,2}; {0,1}; {1,1.5,2}];

% Define the model (in this case, a simple function)
model = @(x) x(:,1).^2 + x(:,2).^3 + x(:,3).^4;

% Generate a set of input parameter samples using LHS
nsamples = 1000;
samples = lhsdesign(nsamples, numel(parameters));
for i = 1:numel(parameters)
    switch distributions{i}
        case 'normal'
            samples(:,i) = norminv(samples(:,i), 0, paramspec{i}(1));
        case 'uniform'
            samples(:,i) = unifinv(samples(:,i), paramspec{i}(1), paramspec{i}(2));
        case 'beta'
            samples(:,i) = betainv(samples(:,i), paramspec{i}(1), paramspec{i}(2), paramspec{i}(3));
    end
end

% Evaluate the model for each sample
outputs = model(samples);

% Compute the sensitivity indices using the Sobol method
[ST, T] = sensSobol(outputs, samples);
981 chars
28 lines

The sensSobol function can be found in the MATLAB Global Sensitivity Analysis Toolbox (GlobalSA), which can be downloaded from the MATLAB File Exchange. The ST output is the total sensitivity index and T output is the first-order sensitivity indices.

gistlibby LogSnag