Skip to content
Josh Fogg edited this page Aug 8, 2024 · 2 revisions
cond(matrix, matrix_inv, max_iterations, tolerance)

Compute the condition number of a matrix, which can be useful for sensitivity analysis of given problems.

Parameters

  • matrix : ArrayLike
    Any matrix or matrix-like object.
  • matrix_inv : ArrayLike, optional
    Any matrix or matrix-like object which exactly is the inverse of the matrix parameter. There's no input checking here, so if this isn't the inverse of matrix then without warning what's returned will not be the condition number. This is optional, and if not provided then cond acts as a wrapper to NumPy's linalg.cond function.
  • max_iterations : int, optional
    Maximum number of iterations if using matrix_inv with the power method, otherwise this is ignored. The default is 5 iterations.
  • tol: float, optional
    Tolerance with which to check convergence if using matrix_inv with the power method, otherwise this is ignored. Default value is $10^{-7}$.

Returns

  • float
    The condition number of the matrix, or the closest approximation using power method if the maximum iteration count was reached.

Notes

If computing the condition number of a matrix it's ordinarily more efficient to compute its largest eigenvalue using power method and then the smallest eigenvalue using the inverse power method. When working with pedigree data however it's relatively cheap to get the inverse of the matrix so it can work out more efficient to compute the largest eigenvalues of the matrix and its inverse both using power method. This usually possible within a relatively small number of iterations too.