otaf.sensitivity package

Module contents

Tools for constructing Sobol sensitivity analysis experiments and plotting results.

class otaf.sensitivity.SobolIndicesExperimentWithComposedDistribution(composedDistribution=None, size=None, second_order=False)[source]

Bases: SobolIndicesExperiment

Sobol indices experiment wrapper using OpenTURNS.

Generates the specialized experimental design matrix (mixture matrix) required for estimating first, second, and total-order Sobol sensitivity indices.

Parameters:
  • composedDistribution (JointDistribution, optional) – The joint distribution of the input variables. Default is None.

  • size (int, optional) – The size \(\mathtt{N}\) of the base samples \(\mathtt{A}\) and \(\mathtt{B}\). Default is None.

  • second_order (bool, optional) – If True, structures the experimental design to allow estimation of second-order Sobol indices. Default is False.

composedDistribution

The joint distribution of the input variables.

Type:

JointDistribution or None

size

The size of the base samples.

Type:

int or None

generate(**kwargs)[source]

Generate and return the final design matrix.

Parameters:

**kwargs (Any) –

Extra keyword arguments. Can include:

methodstr, optional

The sampling method used to generate base designs. Options are 'MonteCarlo', 'LHS', or 'QMC'. Default is 'MonteCarlo'.

sequencestr, optional

The low-discrepancy sequence type. Only evaluated if method is 'QMC'. Options are 'Faure', 'Halton', 'ReverseHalton', 'Haselgrove', or 'Sobol'. Default is 'Sobol'.

Returns:

The combined mixture matrix containing experimental design configurations.

Return type:

ot.Sample

Raises:

AssertionError – If either size or composedDistribution have not been initialized.

generateWithWeights(**kwargs)[source]

Not implemented. Kept for OpenTURNS API compatibility.

Parameters:

kwargs (Any)

Return type:

None

getClassName()[source]

Return the name of the class.

Returns:

The class name string.

Return type:

str

getId()[source]

Return the unique object identifier.

Returns:

The unique ID (memory address) of the instance.

Return type:

int

getName()[source]

Return the name of the object.

Returns:

The internal name assigned to the instance.

Return type:

str

getShadowedId()[source]

Return the shadowed ID of the object.

Returns:

The shadowed identifier.

Return type:

int or None

getSize()[source]

Return the total number of rows in the generated matrix.

Returns:

The row count of the generated design matrix, or 0 if it has not yet been generated.

Return type:

int

getVisibility()[source]

Return the internal visibility flag status.

Returns:

The visibility status tracking parameter.

Return type:

bool

hasName()[source]

Check if the object has a valid, non-empty name.

Returns:

False if __name__ is None or empty; True otherwise.

Return type:

bool

hasUniformWeights()[source]

Not implemented. Kept for OpenTURNS API compatibility.

Returns:

Always returns None.

Return type:

None

hasVisibleName()[source]

Check if the object name is distinct from its default value.

Returns:

False if the name is "Unnamed" or empty; True otherwise.

Return type:

bool

setComposedDistribution(composedDistribution)[source]

Set the joint input distribution.

Parameters:

composedDistribution (JointDistribution) – The new joint distribution model to be assigned.

Return type:

None

setName(name)[source]

Set the internal object name.

Parameters:

name (Any) – The new name (internally cast to string).

Return type:

None

setShadowedId(ids)[source]

Set the shadowed ID parameter.

Parameters:

ids (int) – The shadowed identifier integer.

Return type:

None

setSize(N)[source]

Set the sample size for the base matrices A and B.

Resets all existing generated matrices if the size is updated.

Parameters:

N (int) – The number of rows per base sample. Must be a positive integer.

Raises:

AssertionError – If N is not a positive integer.

Return type:

None

otaf.sensitivity.plotSobolIndicesWithErr(S, errS, varNames, n_dims, Stot=None, errStot=None, dimNames=None, figsize=(20, 10))[source]

Plot Sobol’ indices with error bars.

Visualize estimator uncertainty for sensitivity analysis. Supports plotting for scalar outputs (1D array of indices) using discrete errorbar markers, and vector outputs (2D array of indices) using either subplots or comprehensive heatmaps via an ImageGrid.

Parameters:
  • S (np.ndarray) – First-order Sobol’ indices. Can be of a shape matching the total number of input dimensions n_dims for scalar outputs, or a 2D shape for vector outputs.

  • errS (np.ndarray) – Confidence intervals or errors corresponding to S. Must match the shape of S.

  • varNames (list of str) – Names of the input variables. The length of this list must match n_dims.

  • n_dims (int) – The total number of input variables or dimensions analyzed.

  • Stot (np.ndarray, optional) – Total-order Sobol’ indices. Must match the shape of S. Default is None.

  • errStot (np.ndarray, optional) – Confidence intervals or errors corresponding to Stot. Must match the shape of Stot. Default is None.

  • dimNames (list of str, optional) – Names of the output vector dimensions. Only evaluated for vector outputs in heatmap configurations. Default is None.

  • figsize (tuple of int, default (20, 10)) – Width and height of the target matplotlib figure in inches.

Return type:

None

Notes

The function adapts dynamically based on the dimensionality of S. For high-dimensional vector outputs, it uses heatmaps to manage visual density.