Calculate distance between two vectors of different length

前端 未结 4 809
面向向阳花
面向向阳花 2020-12-16 15:16

There are different methods to calculate distance between two vectors of the same length: Euclidean, Manhattan, Hamming ...

I\'m wondering about any method that woul

4条回答
  •  甜味超标
    2020-12-16 15:47

    The idea of padding the short-sized array with zeros to have the same length like the long-sized array doesn't seem "generally" a correct idea.

    For example, if we have two sets (arrays, vectors,...) of measurements for the same parameter (e.g. temperature, speed or a binary parameter as the status of an on/off switch) made at different time instants. Assume that the first set A1 consists of N measurements made at a set of instants T1 whereas the second set A2 consists of M measurements (M~=N) taken at a set of instants T2.

    Please note that the distribution of T2 arbitrarily differs from that of T1. Thus, padding with zeros here doesn't make sense.

    In this case, I suggest to use interpolation by using a common set of time instants , say T as follows:

    A1_new = interpolate (T1, A1, T);

    A2_new = interpolate (T2, A2, T);

    where interpolate(x,y,xq) accepts the inputs as the variable x, the function y(x) and the query points xq. The 'interpolate' function returns the interpolated output y(xq).

    Now, we can compare the same-size sets A1_new and A2_new by any suitable measure e.g. Euclidean distance.

提交回复
热议问题