tolerancing.sensitivity_analysis#

Sensitivity Analysis Module

This module contains the SensitivityAnalysis class for performing sensitivity analysis on a tolerancing system. The SensitivityAnalysis class allows users to run a sensitivity analysis on a Tolerancing object and visualize the results.

Kramer Harrison, 2024

Classes

SensitivityAnalysis(tolerancing[, sampler])

Class for performing sensitivity analysis on a tolerancing system.

class SensitivityAnalysis(tolerancing: Tolerancing, sampler: BaseSampler | None = None)[source]#

Class for performing sensitivity analysis on a tolerancing system.

Parameters:
  • tolerancing – The tolerancing system to perform sensitivity analysis on.

  • sampler – Optional sampler strategy. Defaults to RangeSampler, which produces a linear sweep for each perturbation. Provide a different BaseSampler subclass to change the sampling behaviour.

Variables:
  • tolerancing – The tolerancing system.

  • operand_names – List of operand names in the tolerancing system.

  • _results – DataFrame storing the sensitivity analysis results.

get_results()[source]#

Returns the results of the sensitivity analysis.

Returns:

The results of the sensitivity analysis.

Return type:

pd.DataFrame

run()[source]#

Run the sensitivity analysis.

This method performs a sensitivity analysis by iterating over the perturbations defined in the tolerancing object. For each perturbation, it applies the perturbation, applies compensators, evaluates operands, and saves the results. The results are stored in a pandas DataFrame in the _results attribute.

Registered perturbations and compensators are reset to their nominal values on exit, including when a trial raises an exception or is interrupted. Results retain the trial values. If a run fails before publishing its DataFrame, results from the last completed run remain available and the exception propagates. Samplers are not rewound.

Raises:

ValueError – If a perturbation sampler other than RangeSampler is used.

view(figsize: tuple[float, float] = (2.5, 3.3), sharex: Literal['none', 'all', 'row', 'col'] | bool = 'col', sharey: Literal['none', 'all', 'row', 'col'] | bool = 'row') → tuple[Figure, list[Axes]][source]#

Visualizes the sensitivity analysis results.

Parameters:
  • figsize (tuple, optional) – The size of the figure in inches for each subplot. Default is (2.2, 3).

  • sharex (str, optional) – Specifies how the x-axis is shared among subplots. Default is ‘col’.

  • sharey (str, optional) – Specifies how the y-axis is shared among subplots. Default is ‘row’.

Returns:

A tuple containing the figure and axes of the plot.

Return type:

tuple