title: Random indices from masked array
body: <p>I have a 2D MaskedArray <code>X</code> and I want to randomly select 30 non-masked elements from it and return their indices <code>idx</code>.</p>
  
  <p>The goal is that I could use the indices to read / set values efficiently later in my code:</p>
  
  <pre><code>selected = X[idx]
  X[idx] = a # some arrays with the same length
  </code></pre>
  
  <p>What is the most efficient way of generating <code>idx</code>?</p>