Skip to main content
`Ctrl`+`K`

# SALib.sample.morris.strategy module

Defines a family of algorithms for generating samples

The sample a for use with `SALib.analyze.morris.analyze`, encapsulate each one, and makes them interchangeable.

Example

    >>> localoptimisation = LocalOptimisation()
    >>> context = SampleMorris(localoptimisation)
    >>> context.sample(input_sample, num_samples, num_params, k_choices, groups)

class SALib.sample.morris.strategy.SampleMorris(strategy)

  Bases: `object`

  Computes the optimum k_choices of trajectories from the input_sample.

  Parameters:

    strategy (`Strategy`)

  Methods

  `sample`(input_sample, num_samples, ...) | Computes the optimum k_choices of trajectories from the input_sample.

  sample(input_sample, num_samples, num_params, k_choices, num_groups)

    Computes the optimum k_choices of trajectories from the input_sample.

    Parameters:

      - input_sample (numpy.ndarray)

      - num_samples (int) – The number of samples to generate

      - num_params (int) – The number of parameters

      - k_choices (int) – The number of optimal trajectories

      - num_groups (int) – The number of groups

    Returns:

      An array of optimal trajectories

    Return type:

      numpy.ndarray

class SALib.sample.morris.strategy.Strategy

  Bases: `object`

  Declare an interface common to all supported algorithms. `SampleMorris` uses this interface to call the algorithm defined by a ConcreteStrategy.

  Methods

  `check_input_sample`(input_sample, num_params, ...) | Check the input_sample is valid
  `compile_output`(input_sample, num_samples, ...) | Picks the trajectories from the input
  `compute_distance`(m, l) | Compute distance between two trajectories
  `compute_distance_matrix`(input_sample, ...[, ...]) | Computes the distance between each and every trajectory
  `run_checks`(number_samples, k_choices) | Runs checks on k_choices
  `sample`(input_sample, num_samples, ...[, ...]) | Computes the optimum k_choices of trajectories from the input_sample.

  static check_input_sample(input_sample, num_params, num_samples)

    Check the input_sample is valid

    Checks input sample is:

      - the correct size

      - values between 0 and 1

    Parameters:

      - input_sample (numpy.ndarray)

      - num_params (int)

      - num_samples (int)

  compile_output(input_sample, num_samples, num_params, maximum_combo, num_groups=None)

    Picks the trajectories from the input

    Parameters:

      - input_sample (numpy.ndarray)

      - num_samples (int)

      - num_params (int)

      - maximum_combo (list)

      - num_groups (int)

  static compute_distance(m, l)

    Compute distance between two trajectories

    Parameters:

      - m (np.ndarray)

      - l (np.ndarray)

    Return type:

      numpy.ndarray

  compute_distance_matrix(input_sample, num_samples, num_params, num_groups=None, local_optimization=False)

    Computes the distance between each and every trajectory

    Each entry in the matrix represents the sum of the geometric distances between all the pairs of points of the two trajectories

    If the groups argument is filled, then the distances are still calculated for each trajectory,

    Parameters:

      - input_sample (numpy.ndarray) – The input sample of trajectories for which to compute the distance matrix

      - num_samples (int) – The number of trajectories

      - num_params (int) – The number of factors

      - num_groups (int, default=None) – The number of groups

      - local_optimization (bool, default=False) – If True, fills the lower triangle of the distance matrix

    Returns:

      distance_matrix

    Return type:

      numpy.ndarray

  static run_checks(number_samples, k_choices)

    Runs checks on k_choices

  sample(input_sample, num_samples, num_params, k_choices, num_groups=None)

    Computes the optimum k_choices of trajectories from the input_sample.

    Parameters:

      - input_sample (numpy.ndarray)

      - num_samples (int) – The number of samples to generate

      - num_params (int) – The number of parameters

      - k_choices (int) – The number of optimal trajectories

      - num_groups (int, default=None) – The number of groups

    Return type:

      numpy.ndarray