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>Based on <a href="http://stackoverflow.com/a/8914682/3627387">http://stackoverflow.com/a/8914682/3627387</a></p>

<pre><code>LARGE_ARRAY = [100,1.8,32,4.1,5,55,34,2.9,1.1,99]
SMALL_ARRAY = [1,2,3,4]

similar = []
for i in SMALL_ARRAY:
    diff_list = [(abs(i - x), x) for x in LARGE_ARRAY]
    diff_list.sort()
    similar.append(diff_list[0][1])

print(similar)
</code></pre>

python arrays