cr.sparse.data.sparse_normal_representations¶
- cr.sparse.data.sparse_normal_representations(key, D, K, S=1)[source]¶
Generates a set of sparse model vectors with normally distributed non-zero entries.
Each vector is K-sparse.
The non-zero basis indexes are randomly selected and shared among all vectors.
The non-zero values are normally distributed.
- Parameters
- Returns
A tuple consisting of (i) a matrix of sparse model vectors (ii) an index set of locations of non-zero entries
- Return type
(jax.numpy.ndarray, jax.numpy.ndarray)
Example
>>> key = random.PRNGKey(1) >>> X, Omega = sparse_normal_representations(key, 6, 2, 3) >>> print(X.shape) (6, 3) >>> print(Omega) [1 5] >>> print(X) [[ 0. 0. 0. ] [ 0.07545021 -1.0032069 -1.1431499 ] [ 0. 0. 0. ] [ 0. 0. 0. ] [ 0. 0. 0. ] [-0.14357079 0.59042295 -1.43841705]]