-1
$\begingroup$

What algorithms are most suitable if I want to strect a time series to a certain length, n. I dont want to just pad the time series with values at the beginning or end, I want the pattern of the data to be followed but with values added anywhere within the time series to make it length n. For example if i have a time series of 4 values: {1, 5, 7, 4} and want to stretch it to 7 values then it would change to: {1, 3, 5, 6, 7, 5.5, 4} and if it was strecthed to 6 values it would still follow the same pattern of the data so it might be something like: {1, 3.5, 5 ,7, 5, 4 } - (this isnt mathematically correct but i hope you get the point)

I would also want this to be applied to a time series that contains x, y, z coordinates eg {x1, y1, z1, x2, y2, z2, ... xn, yn, zn} with the same type of strecthing applied but it takes into account the x, y and z values being related.

Edit: The x, y and z values are the coordinates of a person that is being tracked. So the time series is tracking the movement and actions of a person in a room. For example the person could be running, walking, and moving thoughout the room and the x,y,z coordinates of the person as they are doing that is being tracked.

$\endgroup$
9
  • $\begingroup$ Have you looked up methods of doing linear interpolation between data points? $\endgroup$
    – Kevin Li
    Commented Jul 17, 2018 at 21:25
  • 2
    $\begingroup$ Linear interpolation would work in some applications, but the fact you refer to your data as time series suggests you have a richer concept of the data behavior and wish to capture that with your procedures. Generally, your problem is one of prediction with a change of support. It's not an issue anyone should address without careful consideration of what the data mean, how their values were measured, and the purpose of prediction. For instance, the procedure to use for data that represent averages over finite intervals will differ from that for data representing values at single times. $\endgroup$
    – whuber
    Commented Jul 17, 2018 at 23:37
  • 2
    $\begingroup$ @Nate While your example seems to involve linear interpolation, you essentially need a suitable model (a reasonably accurate description of the process), or your filled in values won't reproduce the characteristics of the values you'd have had if you actually sampled them. No single method will be universally suitable; it depends on situation/ context. If I was interpolating a stock price series I would not expect to be using the same assumptions as if I was interpolating a surface. Additionally, depending on what I was using it for, even interpolating stock prices may need different methods $\endgroup$
    – Glen_b
    Commented Jul 18, 2018 at 4:03
  • 1
    $\begingroup$ ... for example, if the closing price Monday was \$11 and Friday was \$17 and I wanted my best guess at the closing price on Wednesday I might well say \$14 -- but if I was interested in the value of a \$15 call option, that sort of notion would be a really bad idea (variability drives the value, we can't average it away) $\endgroup$
    – Glen_b
    Commented Jul 18, 2018 at 4:09
  • 1
    $\begingroup$ In leau of the situation specific information @Glen_b & whuber request, I think this is adequately covered in the linked thread. Please read it. If it isn't what you want / you still have a question afterwards, come back here & edit your question to state what you learned & what you still need to know. Then we can provide the information you need without just duplicating material elsewhere that already didn't help you. $\endgroup$ Commented Jul 20, 2018 at 13:30

2 Answers 2

1
$\begingroup$

How to stretch a time series to any length, $n$, without padding?

The $x$, $y$ and $z$ values are the coordinates of a person that is being tracked. So the time series is tracking the movement and actions of a person in a room.

Using curve fitting with hysteresis on the $z$. The use of history to confine the $x$ and $y$ complicates things but enhances accuracy. Prior knowledge of the dimensions of the room is better than history of movement but might be different to obtain.

If they go outside they are most likely to travel the same paths as other persons and least likely to walk through solid objects (but those might move over a period of time, confusing the algorithm which must be able to cope with such things, including rearranging the furniture).

This method assumes that they can't walk (or chainsaw) through walls or fly but permits them to walk through doorways and use stairs, yet still produce a smooth track of their position (subject to tracking error). By using hysteresis to confine and predict you can both speed up and enhance the quality of the tracking and run into trouble when you hit an extrema.

$\endgroup$
2
  • $\begingroup$ Thanks for the detailed answer, what if the person was outside but in a confined space? $\endgroup$
    – Nate
    Commented Jul 18, 2018 at 16:07
  • $\begingroup$ @Nate - That would also work. $\endgroup$
    – Rob
    Commented Jul 18, 2018 at 20:04
0
$\begingroup$

It partly depends on how you want the new points to be spread out in time. E.g. you might have data like

time  value
10:01   4
10:02   6
10:03   7
10:04   9

And you want to stretch it to having six (or however many) points. Should the start and end points be 10:01 and 10:04 still? If so, should the new series be equally spread out in time between those, or are you adding the new points in the middle somewhere (which will lead to uneven time intervals).

The most usual version of this is called upsampling. Maybe your data is in 1 minute intervals and you want it to be in 20 second intervals. Then you would "upsample" by adding the new timepoints and then interpolating the value at these new time points from the known values around them. (For more details on upsampling, see e.g. this blog post which talks about using python's pandas package's resample and interpolate functions to do this kind of thing).

If you're just adding new points anywhere between the known points, the principle is similar - add the points, and interpolate the values. There are different versions of interpolation but I think the details are beyond the scope of this answer, look at other answers on this site, e.g. How do I find values not given in (interpolate in) statistical tables?. In your case, linear interpolation would suggest the person is moving at a constant speed in between the known points. Using spline or polynomial interpolation will be smoother and might help capture acceleration.

As far as I understand your question, the fact that you have this x,y,z shouldn't be an issue. Just add the same time points for each of them and interpolate those values and it should roughly match up. E.g. if someone went from x, y, z = (1, 10, 3) to (5, 12, 3) between 10:01 and 10:03 and you are adding the point 10:02, you could use linear interpolation on the vector or on the points individually to guess that at 10:02 their x position was 3, their y position was 11, and the z position was 3. So your guess for their position at 10:02 is (3, 11, 3), which is in the middle of the two known positions.

There is also higher-dimensional interpolation which might be worth looking into (e.g. tricubic interpolation) but I don't know anything about it!

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.