naginterfaces.library.rand.matrix_orthog¶
- naginterfaces.library.rand.matrix_orthog(side, init, statecomm, a)[source]¶
matrix_orthog
generates a random orthogonal matrix.For full information please refer to the NAG Library document for g05px
https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/g05/g05pxf.html
- Parameters
- sidestr, length 1
Indicates whether the matrix is multiplied on the left or right by the random orthogonal matrix .
The matrix is multiplied on the left, i.e., premultiplied.
The matrix is multiplied on the right, i.e., post-multiplied.
- initstr, length 1
Indicates whether or not should be initialized to the identity matrix.
is initialized to the identity matrix.
is not initialized and the matrix must be supplied in .
- statecommdict, RNG communication object, modified in place
RNG communication structure.
This argument must have been initialized by a prior call to
init_repeat()
orinit_nonrepeat()
.- afloat, array-like, shape
If , must contain the matrix .
- Returns
- afloat, ndarray, shape
The matrix when or the matrix when .
- Raises
- NagValueError
- (errno )
On entry, is not valid: .
- (errno )
On entry, is not valid: .
- (errno )
On entry, , .
Constraint: if , ; otherwise .
- (errno )
On entry, , .
Constraint: if , ; otherwise .
- (errno )
On entry, [‘state’] vector has been corrupted or not initialized.
- (errno )
On entry, , .
Constraint: if , ; otherwise .
- (errno )
On entry, , .
Constraint: if , ; otherwise .
- Notes
matrix_orthog
pre - or post-multiplies an matrix by a random orthogonal matrix , overwriting . The matrix may optionally be initialized to the identity matrix before multiplying by , hence is returned. is generated using the method of Stewart (1980). The algorithm can be summarised as follows.Let follow independent multinormal distributions with zero mean and variance and dimensions ; let , where is the identity matrix and is the Householder transformation that reduces to , being the vector with first element one and the remaining elements zero and being a scalar, and let . Then the product is a random orthogonal matrix distributed according to the Haar measure over the set of orthogonal matrices of . See Theorem 3.3 in Stewart (1980).
One of the initialization functions
init_repeat()
(for a repeatable sequence if computed sequentially) orinit_nonrepeat()
(for a non-repeatable sequence) must be called prior to the first call tomatrix_orthog
.
- References
Stewart, G W, 1980, The efficient generation of random orthogonal matrices with an application to condition estimates, SIAM J. Numer. Anal. (17), 403–409