Let's say I have a list of 5 words:

```
[this, is, a, short, list]

```

Furthermore, I can classify some text by counting the occurrences of the words from the list above and representing these counts as a vector:

```
N = [1,0,2,5,10] # 1x this, 0x is, 2x a, 5x short, 10x list found in the given text

```

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):

```
M = [[1,0,2,0,5],
     [0,0,0,0,0],
     [2,0,0,0,20],
     [4,0,8,20,40],
     ...]

```

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.

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.

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)?