signaflo / java-timeseries

Time series analysis in Java
MIT License
197 stars 49 forks source link

Allow simulation of possibly infinite time series #1

Open twiechert opened 7 years ago

twiechert commented 7 years ago

Hi, I use your library in a streaming environment to generate an ARIMA based time series. The simulated time series is supposed to be very long (possibly infinite).

Unfortunately, the whole series is simulated in advance and requires an array of size n. It would be nice to have the possibility to get an "iterator" based time series that allows to retrieve he latest Y_t only, which is then calculated on request. Space complexity should then reduce to max(p,q), right?

Is that something you consider as useful and would possibly implement?

signaflo commented 7 years ago

Hey twiechert,

I'm not sure I would consider it useful to me personally, but so far I have used development of this library mostly as a learning tool, so it could be useful in that regard.

Right now I am putting some finishing touches on release 0.3, which is a major redesign (although the functionality is basically the same, with a few added features). After that release, I'll create a branch for this idea and try to include it in 0.4. Also feel free to fork, modify, and make a pull request. If you run into difficulty modifying the code, let me know, since that means it can probably be written better.

Also, since you're using this for simulation, I'll take this opportunity to let you know that in the next release there will be some breaking changes to the API. I'm renaming ModelCoeffiicients, ModelOrder, etc... to ArimaCoefficients, ArimaOrder, etc... Also, adding the concept of "drift", and clarifying the difference between a process with a drift and one with a mean.

signaflo commented 7 years ago

Twiechert, release 0.4 has replaced ArimaSimulation with ArimaProcess. ArimaProcess does what you suggested and stores only the last number of values needed to generate the next value. Take a look at the source if interested. Ended up using an EvictingQueue from Guava in order to simplify the implementation, but I think it worked out pretty well. Downside is that multi-threaded access could be an issue, so the recommended approach is for the client to use a single thread for each individual ArimaProcess object.

twiechert commented 7 years ago

Hi @signaflo ,

looks really good! You could sync the access to the queue as proposed here https://plus.google.com/+googleguava/posts/QVqQGiSppF3 to allow for multithreaded access.