cr.sparse.data.sparse_spikes¶
- cr.sparse.data.sparse_spikes(key, N, K, S=1)[source]¶
Generates a set of sparse model vectors with Rademacher distributed non-zero entries.
Each vector is K-sparse.
The non-zero basis indexes are randomly selected and shared among all vectors.
Non-zero values are Rademacher distributed spikes (-1, 1).
- 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(3) >>> X, Omega = sparse_spikes(key, 6, 2, 3) >>> print(X.shape) (6, 3) >>> print(Omega) [2 5] >>> print(X) [[ 0. 0. 0.] [ 0. 0. 0.] [-1. 1. 1.] [ 0. 0. 0.] [ 0. 0. 0.] [ 1. -1. 1.]]