make_spd_matrix#

sklearn.datasets.make_spd_matrix(n_dim,*,random_state=None)[source]#

Generate a random symmetric, positive-definite matrix.

Read more in theUser Guide.

Parameters:
n_dimint

The matrix dimension.

random_stateint, RandomState instance or None, default=None

Determines random number generation for dataset creation. Pass an intfor reproducible output across multiple function calls.SeeGlossary.

Returns:
Xndarray of shape (n_dim, n_dim)

The random symmetric, positive-definite matrix.

See also

make_sparse_spd_matrix

Generate a sparse symmetric definite positive matrix.

Examples

>>>fromsklearn.datasetsimportmake_spd_matrix>>>make_spd_matrix(n_dim=2,random_state=42)array([[2.093, 0.346],       [0.346, 0.218]])
On this page

This Page