Using Numpy to generate random combinations of two arrays without repetition
<p>Given two arrays, for example <code>[0,0,0]</code> and <code>[1,1,1]</code>, it is already clear (see <a href="https://stackoverflow.com/questions/1208118/using-numpy-to-build-an-array-of-all-combinations-of-two-arrays">here</a>) how to generate all the combinations, i.e., <code>[[0,0,0],[0,0,1],[0,1,0],[0,1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1]]</code>. <code>itertools</code> (<code>combinations</code> or <code>product</code>) and <code>numpy.meshgrid</code> are the most common ways as far as I know.</p>

<p>However, I could't find any discussions on how to generate this combinations randomly, without repetitions. </p>

<p>An easy solution could be to generate all the combinations and then choose some of them randomly. For example:</p>

<pre><code># Three random combinations of [0,0,0] and [1,1,1]
comb = np.array(np.meshgrid([0,1],[0,1],[0,1])).T.reshape(-1,3)
result = comb[np.random.choice(len(comb),3,replace=False),:]
</code></pre>

<p>However, this is infeasible when the number of combinations is too big.</p>

<p>Is there a way to generate random combinations without replacement in Python (possibly with Numpy) without generating all the combinations?</p>

<p><strong>EDIT</strong>: You can notice in the accepted answer that we also got for free a technique to generate <strong>random binary vectors without repetitions</strong>, which is just a single line (described in the <em>Bonus Section</em>).</p>