0

The task is following, i am looking for a method to "align" two vectors o each other, before calculating the distance between them like Euclidean distance. The reason is, that some entries in the vectors may be missing, but i do not know what exactly. For example, if i have the vector [1,50,100] and other [2, 101], it is obvious that they should be aligned as

[1,50,100] [2, X, 101]. 

Means, during the alignment, i need to find the variant, what would give minimum length between existing values. If this is for longer vector length, the alignment may be confusing, but if i align vectors wrong, like [1,50,100] [2, 101, X] -> this distance is not desirable. Do you have any suggestions how to calculate this distance?

Smer5
  • 33
  • 1
    What is "obvious" to you is not obvious to me at all. Are you talking about mathematical vectors, or are you talking about the kind of "vector" you might see in a programming language, which is really just a list of numbers? And in either case, how would you define Euclidean distance between two "vectors"? – David K Sep 21 '23 at 02:36
  • mathematical vectors and programming language list or vector are the same. Euclid is square root of summ of squares of difference of elements in 2 vectors in the same position. I want to align vectors, where some positions may be not be present or fit each other, so values in same positions of both vectors would be as similar to each other as possible – Smer5 Sep 21 '23 at 02:44
  • 2
    A vector in $\Bbb{R}^3$ and a vector $\Bbb{R}^2$ are in different spaces. There's no universally accepted definition of distance that applies to two such vectors. You could potentially define such a distance, one that's helpful for whatever problem you're working on, but we can't really help you with that unless we know what problem you're trying to solve. – Theo Bendit Sep 21 '23 at 02:48
  • 1
    "mathematical vectors and programming language list or vector are the same." Only if you have a very limited knowledge of mathematical vectors. https://math.stackexchange.com/a/1937983/139123 – David K Sep 21 '23 at 03:46
  • 2
    You have lists of numbers (not vectors -- you'll get better responses by deleting all mention of that word from your question), and you almost have a rule for computing a "distance" between two lists of numbers by skipping some entries while aligning the two lists with each other. Then only the numbers in positions that have been aligned with each other are counted in the Euclidean distance. I say you "almost" have a rule, because if I fill in the "missing entries" in $[1,50,100]$ and $[2,101]$ like this -- $[1,50,100,X,X]$ and $[X,X,X,2,101]$ -- then I get a distance of zero. – David K Sep 21 '23 at 03:52
  • So you need a more specific rule that will say when it is permitted to insert an $X$ in a list and when it is not. – David K Sep 21 '23 at 03:53
  • I will assume that you know the largest number of elements the vectors can be. I think the only way is to try every possible subtraction and see which one yields the smallest distance. Since order of the elements must be maintained, this isn’t that many possibilities. – NicNic8 Sep 21 '23 at 04:27
  • How important is order here? For instance, if you have $[1, 50, 100]$ and $[101,2]$, would $[1, 50, 100]$ and $[2, X, 101]$ still be allowable? Or would it have to be $[X, 101, 2]$ as the closest? – Paul Sinclair Sep 21 '23 at 20:39
  • @Paul Sinclair the vectors are originally sorted in increasing order. – Smer5 Sep 22 '23 at 01:50

0 Answers0