Skip to content

Feature request: [your feature] #694

@nxd914

Description

@nxd914

Is your feature request related to a problem?
Yes. While fix_nonpositive_semidefinite correctly detects and fixes non-PSD covariance matrices, covariance matrices that are positive semidefinite but highly ill-conditioned can still lead to numerical instability during inversion and optimization (e.g. in EfficientFrontier solvers). Currently, these cases pass silently despite being potentially problematic.

Describe the feature you'd like
I propose emitting a warning when a covariance matrix is positive semidefinite but has a very large condition number, indicating numerical ill-conditioning. The warning would suggest using shrinkage estimators (e.g. Ledoit-Wolf or OAS) to improve numerical stability.

This would not change the public API or default behavior of the library — it would only add a warning in potentially unstable cases.

Additional context
This is motivated by standard numerical linear algebra practice, where PSD does not imply stable inversion if the condition number is large. Similar warnings are commonly used in scientific computing libraries to guide users toward more stable estimators without enforcing behavioral changes.

I am happy to add unit tests to ensure the warning is raised appropriately and does not affect existing functionality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions