4 ms·
"a fully managed TimescaleDB service" Weighted averaging as a commercial service, all by itself? The SQL solution seems complicated, but this is a task easily
by Animats 5y ago
"a fully managed TimescaleDB service"
Weighted averaging as a commercial service, all by itself? The SQL solution seems complicated, but this is a task easily performed on time-ordered data.
I had to code such a time-weighted average last year, for a game client. The client gets updates for moving objects when they move a small distance or when some dwell time has elapsed. I needed a smoothed velocity from those irregularly spaced samples. The math had to be worked out, but it was just two lines of C++ in the implementation.[1]
filtermult = 1.0f - 1.0f / pow(1.0f + 1.0f / fsRegionCrossingSmoothingTime, secs); // filter scale factor
mFiltered = val * filtermult + mFiltered * (1.0f - filtermult); // low pass filter
[1] https://vcs.firestormviewer.org/phoenix-firestorm/files/tip/indra/newview/fsregioncross.cpp https://vcs.firestormviewer.org/phoenix-firestorm/files/tip/...
- PaulWaldman 5y ago>Weighted averaging as a commercial service, all by itself? No. The full quote is: "If you’d like to get started with the time_weight hyperfunction - and many more - right away, spin up a fully managed TimescaleDB service" They're just indicating you can try this with their hosted TimescaleDB service. Not that this a standalone service.
- KarlKode 5y agoTimescale is a postgres extension that allows you to store time series data in a postgres database. Besides offering a very performant way to store specialized data it also offers additional functions to work with your time series data. Besides the postgres extension there is also a database-as-a-service option where you can get started immediately and try the technique described in the blogpost.
- g8oz 5y agoA data analyst is more likely to know SQL rather than C++.
- Animats 5y agoMy point is that this is easy to do if you just have the data in sequence. The actual computation could be done in Matlab, or Julia, or R, or Python. SQL isn't a good language for doing computations on time-series data, but you can always write out a sorted data list.
- nl 5y agotime window functions exist in SQL now and are great.
- lupire 5y agoThat looks like a non-linear time-decay function, not a time-weighted average. Why are you setting filtermult=1-stuff and then immediately doing 1-filtermult?