title: How to find most similar numerical arrays to one array, using Numpy/Scipy?
body: <p>Let's say I have a list of 5 words:</p>
  
  <pre><code>[this, is, a, short, list]
  </code></pre>
  
  <p>Furthermore, I can classify some text by counting the occurrences of the words from the list above and representing these counts as a vector:</p>
  
  <pre><code>N = [1,0,2,5,10] # 1x this, 0x is, 2x a, 5x short, 10x list found in the given text
  </code></pre>
  
  <p>In the same way, I classify many other texts (count the 5 words per text, and represent them as counts - each row represents a different text which we will be comparing to N):</p>
  
  <pre><code>M = [[1,0,2,0,5],
       [0,0,0,0,0],
       [2,0,0,0,20],
       [4,0,8,20,40],
       ...]
  </code></pre>
  
  <p>Now, I want to find the top 1 (2, 3 etc) rows from M that are most similar to N. Or on simple words, the most similar texts to my initial text.</p>
  
  <p>The challenge is, just checking the distances between N and each row from M is not enough, since for example row M4 [4,0,8,20,40] is very different by distance from N, but still proportional (by a factor of 4) and therefore very similar. For example, the text in row M4 can be just 4x as long as the text represented by N, so naturally all counts will be 4x as high.</p>
  
  <p>What is the best approach to solve this problem (of finding the most 1,2,3 etc similar texts from M to the text in N)?</p>