random_sparse_spd_matrix¶
-
probnum.problems.zoo.linalg.random_sparse_spd_matrix(dim, density, chol_entry_min=0.1, chol_entry_max=1.0, random_state=None)[source]¶ Random sparse symmetric positive definite matrix.
Constructs a random sparse symmetric positive definite matrix for a given degree of sparsity. The matrix is constructed from its Cholesky factor \(L\). Its diagonal is set to one and all other entries of the lower triangle are sampled from a uniform distribution with bounds
[chol_entry_min, chol_entry_max]. The resulting sparse matrix is then given by \(A=LL^\top\).- Parameters
dim (
Integral) – Matrix dimension.density (
float) – Degree of sparsity of the off-diagonal entries of the Cholesky factor. Between 0 and 1 where 1 represents a dense matrix.chol_entry_min (
float) – Lower bound on the entries of the Cholesky factor.chol_entry_max (
float) – Upper bound on the entries of the Cholesky factor.random_state (
Union[None,int,RandomState,Generator]) – Random state of the random variable. If None (or np.random), the globalnumpy.randomstate is used. If integer, it is used to seed the localRandomStateinstance.
See also
random_spd_matrix()Generate a random symmetric positive definite matrix.
Examples
>>> from probnum.problems.zoo.linalg import random_sparse_spd_matrix >>> sparsemat = random_sparse_spd_matrix(dim=5, density=0.1, random_state=42) >>> sparsemat array([[1. , 0. , 0. , 0. , 0. ], [0. , 1. , 0. , 0. , 0. ], [0. , 0. , 1. , 0. , 0.24039507], [0. , 0. , 0. , 1. , 0. ], [0. , 0. , 0.24039507, 0. , 1.05778979]])
- Return type