naginterfaces.library.correg.corrmat_fixed¶
- naginterfaces.library.correg.corrmat_fixed(g, alpha, h, m, errtol=0.0, maxit=0)[source]¶
corrmat_fixed
computes the nearest correlation matrix, in the Frobenius norm, while fixing elements and optionally with bounds on the eigenvalues, to a given square input matrix.For full information please refer to the NAG Library document for g02as
https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/g02/g02asf.html
- Parameters
- gfloat, array-like, shape
, the initial matrix.
- alphafloat
The value of .
If , a value of is used.
- hint, array-like, shape
The symmetric matrix . If an element of is then the corresponding element in is fixed in the output . Only the strictly lower triangular part of need be set.
- mint
The number of previous iterates to use in the Anderson acceleration. If , Anderson acceleration is not used. See Accuracy for further details.
If , a value of is used.
- errtolfloat, optional
The termination tolerance for the iteration.
If , is used.
See Accuracy for further details.
- maxitint, optional
Specifies the maximum number of iterations.
If , a value of is used.
- Returns
- xfloat, ndarray, shape
Contains the matrix .
- itsint
The number of iterations taken.
- fnormfloat
The value of after the final iteration.
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, and .
Constraint: .
- (errno )
Function failed to converge in iterations.
A solution may not exist, however, try increasing .
- (errno )
Failure during Anderson acceleration.
Consider setting and recomputing.
- (errno )
The fixed element , lies outside the interval , for and .
- Notes
corrmat_fixed
finds the nearest correlation matrix, , to a matrix, , in the Frobenius norm. It uses an alternating projections algorithm with Anderson acceleration. Elements in the input matrix can be fixed by supplying the value in the corresponding element of the matrix . However, note that the algorithm may fail to converge if the fixed elements do not form part of a valid correlation matrix. You can optionally specify a lower bound, , on the eigenvalues of the computed correlation matrix, forcing the matrix to be positive definite with .
- References
Anderson, D G, 1965, Iterative Procedures for Nonlinear Integral Equations, J. Assoc. Comput. Mach. (12), 547–560
Higham, N J and Strabić, N, 2016, Anderson acceleration of the alternating projections method for computing the nearest correlation matrix, Numer. Algor. (72), 1021–1042