Random matrices: Haar orthogonal groups, correlation matrices, Wishart family, matrix normal.
Methods
(static) determinant(a) → {number}
Determinant by Gaussian elimination with partial pivoting.
Parameters:
| Name | Type | Description |
|---|---|---|
a |
Array.<Array.<number>> |
Returns:
- Type
- number
(static) invWishart(df, scale, sizeopt) → {Array.<Array.<number>>|Array}
Draws matrices from the inverse Wishart distribution, as scipy.stats.invwishart.
The mean is scale / (df - dim - 1) for df > dim + 1.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
df |
number | Degrees of freedom (> dim - 1). |
||
scale |
Array.<Array.<number>> | Symmetric positive definite scale matrix. |
||
size |
number | Array.<number> | null |
<optional> |
null | Output shape (each element is a matrix). |
Returns:
- Type
- Array.<Array.<number>> | Array
(static) inverseSPD(a) → {Array.<Array.<number>>}
Inverse of a symmetric positive definite matrix through its Cholesky factor.
Parameters:
| Name | Type | Description |
|---|---|---|
a |
Array.<Array.<number>> |
Returns:
- Type
- Array.<Array.<number>>
(static) lkjCorrelation(dim, etaopt, sizeopt, choleskyopt) → {Array.<Array.<number>>|Array}
Draws correlation matrices from the LKJ distribution (Lewandowski, Kurowicka & Joe, 2009),
with density proportional to det(R)^(eta - 1). eta = 1 is uniform over correlation
matrices; larger eta concentrates around the identity. The usual prior in Bayesian models.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
dim |
number | Matrix dimension. |
||
eta |
number |
<optional> |
1 | Concentration (> 0). |
size |
number | Array.<number> | null |
<optional> |
null | Output shape (each element is a matrix). |
cholesky |
boolean |
<optional> |
false | Return the lower Cholesky factor instead of the matrix. |
Returns:
- Type
- Array.<Array.<number>> | Array
(static) matrixNormal(mean, rowCov, colCov, sizeopt) → {Array.<Array.<number>>|Array}
Draws matrices from the matrix normal distribution MN(mean, rowCov, colCov):
X = mean + A Z Bᵀ with rowCov = A Aᵀ, colCov = B Bᵀ and Z standard normal,
as scipy.stats.matrix_normal.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
mean |
Array.<Array.<number>> | n x p mean matrix. |
||
rowCov |
Array.<Array.<number>> | n x n among-row covariance. |
||
colCov |
Array.<Array.<number>> | p x p among-column covariance. |
||
size |
number | Array.<number> | null |
<optional> |
null | Output shape (each element is a matrix). |
Returns:
- Type
- Array.<Array.<number>> | Array
(static) orthoGroup(dim, sizeopt) → {Array.<Array.<number>>|Array}
Draws Haar-distributed (uniformly random) orthogonal matrices from O(n),
as scipy.stats.ortho_group.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
dim |
number | Matrix dimension. |
||
size |
number | Array.<number> | null |
<optional> |
null | Output shape (each element is a matrix). |
Returns:
- Type
- Array.<Array.<number>> | Array
(static) randomCorrelation(eigs, sizeopt) → {Array.<Array.<number>>|Array}
Draws random correlation matrices with the given eigenvalues (Davies & Higham, 2000),
as scipy.stats.random_correlation.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
eigs |
Array.<number> | Non-negative eigenvalues summing to their count. |
||
size |
number | Array.<number> | null |
<optional> |
null | Output shape (each element is a matrix). |
Returns:
- Type
- Array.<Array.<number>> | Array
(static) specialOrthoGroup(dim, sizeopt) → {Array.<Array.<number>>|Array}
Draws Haar-distributed rotation matrices from SO(n) (determinant +1),
as scipy.stats.special_ortho_group.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
dim |
number | Matrix dimension. |
||
size |
number | Array.<number> | null |
<optional> |
null | Output shape (each element is a matrix). |
Returns:
- Type
- Array.<Array.<number>> | Array
(static) wishart(df, scale, sizeopt) → {Array.<Array.<number>>|Array}
Draws matrices from the Wishart distribution W(df, scale) using the Bartlett decomposition,
as scipy.stats.wishart. The mean is df * scale.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
df |
number | Degrees of freedom (> dim - 1). |
||
scale |
Array.<Array.<number>> | Symmetric positive definite scale matrix. |
||
size |
number | Array.<number> | null |
<optional> |
null | Output shape (each element is a matrix). |
Returns:
- Type
- Array.<Array.<number>> | Array