SALib.sample package

Submodules

SALib.sample.common_args module

SALib.sample.common_args.create(cli_parser=None)[source]

Create CLI parser object.

Parameters:cli_parser (function [optional]) – Function to add method specific arguments to parser
Returns:
Return type:argparse object
SALib.sample.common_args.run_cli(cli_parser, run_sample, known_args=None)[source]

Run sampling with CLI arguments.

Parameters:
  • cli_parser (function) – Function to add method specific arguments to parser
  • run_sample (function) – Method specific function that runs the sampling
  • known_args (list [optional]) – Additional arguments to parse
Returns:

Return type:

argparse object

SALib.sample.common_args.setup(parser)[source]

Add common sampling options to CLI parser.

Parameters:parser (argparse object) –
Returns:
Return type:Updated argparse object

SALib.sample.directions module

SALib.sample.fast_sampler module

SALib.sample.fast_sampler.cli_action(args)[source]

Run sampling method

Parameters:args (argparse namespace) –
SALib.sample.fast_sampler.cli_parse(parser)[source]

Add method specific options to CLI parser.

Parameters:parser (argparse object) –
Returns:
Return type:Updated argparse object
SALib.sample.fast_sampler.sample(problem, N, M=4, seed=None)[source]

Generate model inputs for the Fourier Amplitude Sensitivity Test (FAST).

Returns a NumPy matrix containing the model inputs required by the Fourier Amplitude sensitivity test. The resulting matrix contains N rows and D columns, where D is the number of parameters. The samples generated are intended to be used by SALib.analyze.fast.analyze().

Parameters:
  • problem (dict) – The problem definition
  • N (int) – The number of samples to generate
  • M (int) – The interference parameter, i.e., the number of harmonics to sum in the Fourier series decomposition (default 4)

SALib.sample.ff module

The sampling implementation of fractional factorial method

This implementation is based on the formulation put forward in [Saltelli et al. 2008]

SALib.sample.ff.cli_action(args)[source]

Run sampling method

Parameters:args (argparse namespace) –
SALib.sample.ff.cli_parse(parser)[source]

Add method specific options to CLI parser.

Parameters:parser (argparse object) –
Returns:
Return type:Updated argparse object
SALib.sample.ff.extend_bounds(problem)[source]

Extends the problem bounds to the nearest power of two

Parameters:problem (dict) – The problem definition
SALib.sample.ff.find_smallest(num_vars)[source]

Find the smallest exponent of two that is greater than the number of variables

Parameters:num_vars (int) – Number of variables
Returns:x – Smallest exponent of two greater than num_vars
Return type:int
SALib.sample.ff.generate_contrast(problem)[source]

Generates the raw sample from the problem file

Parameters:problem (dict) – The problem definition
SALib.sample.ff.sample(problem, seed=None)[source]

Generates model inputs using a fractional factorial sample

Returns a NumPy matrix containing the model inputs required for a fractional factorial analysis. The resulting matrix has D columns, where D is smallest power of 2 that is greater than the number of parameters. These model inputs are intended to be used with SALib.analyze.ff.analyze().

The problem file is padded with a number of dummy variables called dummy_0 required for this procedure. These dummy variables can be used as a check for errors in the analyze procedure.

This algorithm is an implementation of that contained in [Saltelli et al. 2008]

Parameters:problem (dict) – The problem definition
Returns:sample
Return type:numpy.array

SALib.sample.finite_diff module

SALib.sample.finite_diff.cli_action(args)[source]

Run sampling method

Parameters:args (argparse namespace) –
SALib.sample.finite_diff.cli_parse(parser)[source]

Add method specific options to CLI parser.

Parameters:parser (argparse object) –
Returns:
Return type:Updated argparse object
SALib.sample.finite_diff.sample(problem, N, delta=0.01, seed=None)[source]

SALib.sample.latin module

SALib.sample.latin.cli_action(args)[source]

Run sampling method

Parameters:args (argparse namespace) –
SALib.sample.latin.cli_parse(parser)[source]

Add method specific options to CLI parser.

Parameters:parser (argparse object) –
Returns:
Return type:Updated argparse object
SALib.sample.latin.sample(problem, N, seed=None)[source]

Generate model inputs using Latin hypercube sampling (LHS).

Returns a NumPy matrix containing the model inputs generated by Latin hypercube sampling. The resulting matrix contains N rows and D columns, where D is the number of parameters.

Parameters:
  • problem (dict) – The problem definition
  • N (int) – The number of samples to generate

SALib.sample.saltelli module

SALib.sample.saltelli.cli_action(args)[source]

Run sampling method

Parameters:args (argparse namespace) –
SALib.sample.saltelli.cli_parse(parser)[source]

Add method specific options to CLI parser.

Parameters:parser (argparse object) –
Returns:
Return type:Updated argparse object
SALib.sample.saltelli.sample(problem, N, calc_second_order=True, seed=None)[source]

Generates model inputs using Saltelli’s extension of the Sobol sequence.

Returns a NumPy matrix containing the model inputs using Saltelli’s sampling scheme. Saltelli’s scheme extends the Sobol sequence in a way to reduce the error rates in the resulting sensitivity index calculations. If calc_second_order is False, the resulting matrix has N * (D + 2) rows, where D is the number of parameters. If calc_second_order is True, the resulting matrix has N * (2D + 2) rows. These model inputs are intended to be used with SALib.analyze.sobol.analyze().

Parameters:
  • problem (dict) – The problem definition
  • N (int) – The number of samples to generate
  • calc_second_order (bool) – Calculate second-order sensitivities (default True)

SALib.sample.sobol_sequence module

SALib.sample.sobol_sequence.index_of_least_significant_zero_bit(value)[source]
SALib.sample.sobol_sequence.sample(N, D)[source]

Generate (N x D) numpy array of Sobol sequence samples

Module contents