python sample large array using smaller array
<p>Let's say I have two arrays: SMALL_ARRAY and LARGE_ARRAY
The LARGE_ARRAY contains values that are similar in value (not necessarily the same)
I would like to get a subarray of the LARGE_ARRAY that:</p>

<p>= Has same size as SMALL_ARRAY</p>

<p>= Has similar values (similar distribution) as SMALL_ARRAY</p>

<p>let's assume small = [1,2,3,4] and large = [100,1.8,32,4.1,5,55,34,2.9,1.1,99]</p>

<p>I would like my new array to be [1.1,1.8,2.9,4.1]</p>

<p>so it has same size and similar elements to small</p>

<p>Any assistance please?
Many thanks</p>

<p><code>numpy.random.choice</code> is your friend if you want to subsample uniformly at random:</p>

<pre><code>import numpy as np

# 'initialise' small so we know its shape
# obviously you can skip that step if you already know the shape
m, n = 5, 10
small = np.zeros((m, n))

# get a sample from a large array
large = np.random.randn(100,1000)
samples = np.random.choice(large.ravel(), size=m*n)

#  small
small = samples.reshape(small.shape)

print small
</code></pre>

python arrays