title: Keep random values from matrix
body: <p>I have a matrix, which contains N entries each with M rows. Each row contains of 0s and 1s. I want to create a second matrix with the same size, but in each row only one 1 should be left, every other value should be 0. Which value should be 1 should be chosen randomly.</p>
  
  <p>E.g.:</p>
  
  <pre><code>0 1 1 0 1
  1 1 0 0 1
  0 0 1 1 0
  -&gt;
  0 1 0 0 0
  1 0 0 0 0
  0 0 0 1 0
  </code></pre>