influxdata / influxdata/influxdb
Mean of circular quantities
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
__Proposal:__
Add a function which calculates the proper mean of circular quantities.
__Current behavior:__
InfluxDB provides a `mean()` function, good for _linear_ quantities, but not the proper approach for _circular_ quantities, like angles. The "mean" value of 350 degree and 20 degree should give about 10 degree, and obviously not 185 degree, as `mean()` would return.
__Desired behavior:__
The proper way of calculating the mean of circular quantities is well known, see https://en.wikipedia.org/wiki/Mean_of_circular_quantities, and is in a nutshell
```
atan2 ( mean (sin(x), mean (cos(x) )
```
A `circular_mean()` function would most likely have to more arguments
- to control the scale (e.g. radian, degree)
- to control whether the result is `[0,scale[` or `[-.5*scale,+0.5*scale[`
__Use case:__
Currently it's cumbersome to treat angles in InfluxDB. Angles are quite common in technical measurements (e.g. orientation of a device). Even `telegraf` generates them out-of-the-box (the wind direction returned by the openweathermap input plugin).
Contributor guide
Assessment
This issue has not been assessed yet.