nlsq.diagnostics.ParameterSensitivityAnalyzer

class nlsq.diagnostics.ParameterSensitivityAnalyzer(config=None)[source]

Bases: object

Analyzer for parameter sensitivity spectrum from Jacobian matrices.

This class analyzes the eigenvalue spectrum of the Fisher Information Matrix (FIM) to identify well-determined vs poorly-determined parameter directions. It detects wide eigenvalue spread when eigenvalues span many orders of magnitude.

Parameters:

config (DiagnosticsConfig | None) – Configuration containing thresholds for sensitivity analysis. If None, uses default configuration.

config

Configuration for the analyzer.

Type:

DiagnosticsConfig

Notes

Detection logic:

  • A model is considered to have wide eigenvalue spread when its eigenvalue range exceeds a threshold derived from the config’s sloppy_threshold.

  • The sloppy_threshold (default 1e-6) defines when a direction is classified as poorly-determined: eigenvalue < threshold * max_eigenvalue.

  • The overall is_sloppy flag is set when eigenvalue range (in orders of magnitude) is significant enough to cause practical issues.

Examples

>>> import numpy as np
>>> from nlsq.diagnostics import DiagnosticsConfig
>>> from nlsq.diagnostics.parameter_sensitivity import ParameterSensitivityAnalyzer
>>> config = DiagnosticsConfig()
>>> analyzer = ParameterSensitivityAnalyzer(config)
>>> J = np.random.randn(100, 3)  # 100 data points, 3 parameters
>>> report = analyzer.analyze(J)
>>> print(report.is_sloppy)
False
DEFAULT_SLOPPY_DETECTION_ORDERS = 2.0
STIFF_RATIO_THRESHOLD = 0.1
SLOPPY_RATIO_THRESHOLD = 0.01
__init__(config=None)[source]

Initialize the parameter sensitivity analyzer.

Parameters:

config (DiagnosticsConfig | None) – Configuration containing analysis thresholds. If None, uses default configuration.

analyze(jacobian)[source]

Analyze parameter sensitivity spectrum from a Jacobian matrix.

Computes the Fisher Information Matrix (FIM) as J.T @ J and analyzes its eigenvalue spectrum for wide eigenvalue spread.

Parameters:

jacobian (np.ndarray) – Jacobian matrix of shape (n_data, n_params).

Returns:

Report containing analysis results and any detected issues.

Return type:

ParameterSensitivityReport

Notes

The analysis includes:

  1. FIM computation: FIM = J.T @ J

  2. Eigenvalue decomposition for spectrum analysis

  3. Eigenvalue range computation (log10 ratio)

  4. Stiff/poorly-determined direction classification

  5. Effective dimensionality using participation ratio

  6. Issue detection based on thresholds

analyze_from_fim(fim)[source]

Analyze parameter sensitivity spectrum from a pre-computed FIM.

Parameters:

fim (np.ndarray) – Fisher Information Matrix of shape (n_params, n_params).

Returns:

Report containing analysis results and any detected issues.

Return type:

ParameterSensitivityReport