Let P be an array where each row sums up to 1. How can I generate a matrix A where
-
A has the same dimensions as P, and has A_{ij} equal to 1 with probability P_{ij}
-
A has exactly one entry equal to 1 in every row, with all other entries zero
How can I do this in Numpy or Scipy?
I can do it using for-loops, but that's obviously slow. Is there a way to use Numpy to accelerate it? Or Numba?
Aucun commentaire:
Enregistrer un commentaire