An approach with a time window does not work for computing time weighted 
average as you may have windows with no chainges at all or a change after 
the beginning of the window and in those two cases you will not have access 
to the actual value of your sensor during the whole or part of the time 
window.

Your best option so far is probably to fill the data with the previous 
value with a regularized series (regular ticks) and then compute the 
average on this transformed series. The computed value for first and last 
window will be incorrect but that can be mitigated by increasing your time 
range.

On Saturday, October 15, 2016 at 4:11:34 AM UTC+2, dea...@hotmail.com wrote:
>
> Hi Sean,
>
> Thanks for the reply. I did run up a sample database with some time 
> weighted samples and unfortunately the moving average ignores the time that 
> the data is stored so doesn't help.
>
> I also had a look at pull 6113 and there is a lot of code in a language & 
> platform I'm unfamiliar with, and its difficult to work out what routines 
> to modify. 
>
> There are 2 ways to implement a time weighted average, firstly to 
> interpolate like how openTSDB does it, which for some IoT sensor scenarios 
> is useful if there is lost data or data resolution needs to be more 
> granular. However the other common IoT scenario I'm trying to solve for is 
> when the sensor reacts to changes - a better model as it reduces network 
> bandwidth, storage and CPU usage as well as increases battery life for 
> remote sensors compared to regular time interval data collection.
>
> To implement a time weighted average from irregular time samples shouldn't 
> be that tough, I have it implemented previously at the application layer, 
> basically:
> 1) You want the <window> parameter in the moving average query function to 
> be time based, not number of points. 
> 2) Each sample is weighted by the time delta between itself and the 
> previous sample as a proportion to the time window size.
> 3) Add up these weighted samples to get the average.
> 4) Would also work as continuous query.
>
> Keep up the good work on influxdb - I like the approach you have taken. I 
> will be using it for my IoT solution that will be open sourced soon 
> although I need to find an alternative solution to the time weighted 
> average at some point. Hopefully you can see the benefit in a time weighted 
> average function for a time series database targeted for IoT scenarios - I 
> would have a try at writing this function but would need help with Go & 
> your platform code.
>
> Regards
> Dean
>
>

-- 
Remember to include the version number!
--- 
You received this message because you are subscribed to the Google Groups 
"InfluxData" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to influxdb+unsubscr...@googlegroups.com.
To post to this group, send email to influxdb@googlegroups.com.
Visit this group at https://groups.google.com/group/influxdb.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/influxdb/6071b627-2b2d-4479-a074-86e8be31d796%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to