{"action":"created","issue":{"url":"https://api.github.com/repos/influxdb/influxdb/issues/3344","labels_url":"https://api.github.com/repos/influxdb/influxdb/issues/3344/labels{/name}","comments_url":"https://api.github.com/repos/influxdb/influxdb/issues/3344/comments","events_url":"https://api.github.com/repos/influxdb/influxdb/issues/3344/events","html_url":"https://github.com/influxdb/influxdb/pull/3344","id":95441594,"number":3344,"title":"Add an aggregation function for integration using Riemann sums.","user":{"login":"michaelsproul","id":4452260,"avatar_url":"https://avatars.githubusercontent.com/u/4452260?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelsproul","html_url":"https://github.com/michaelsproul","followers_url":"https://api.github.com/users/michaelsproul/followers","following_url":"https://api.github.com/users/michaelsproul/following{/other_user}","gists_url":"https://api.github.com/users/michaelsproul/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelsproul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelsproul/subscriptions","organizations_url":"https://api.github.com/users/michaelsproul/orgs","repos_url":"https://api.github.com/users/michaelsproul/repos","events_url":"https://api.github.com/users/michaelsproul/events{/privacy}","received_events_url":"https://api.github.com/users/michaelsproul/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":20,"created_at":"2015-07-16T14:10:06Z","updated_at":"2015-07-28T02:14:07Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/influxdb/influxdb/pulls/3344","html_url":"https://github.com/influxdb/influxdb/pull/3344","diff_url":"https://github.com/influxdb/influxdb/pull/3344.diff","patch_url":"https://github.com/influxdb/influxdb/pull/3344.patch"},"body":"I'd really like an integration aggregation function, so I've written one. At present it only works for `float64` values. Some help making this idiomatic Go would be appreciated. I rarely write Go and don't know all the best practices for dealing with `interface{}`.\r\n\r\nAnother thing up for discussion is how to deal with the (physical) time unit used during integration. Timestamps are stored as nanoseconds but it seems impractical to make people always deal with for example `W ns` values when integrating power (`W`) over time. For now I've just made the integration unit seconds.\r\n\r\nAlso up for discussion is what type of Riemann sum to use. At the moment this is a **left Riemann** sum, as that makes the most sense for my particular data-set. The way I see it is that the value stored at a given timestamp would generally *persist* until the next point is inserted. This makes the area of a single block:\r\n\r\n```\r\nA_i = v_i * (t_(i + 1) - t_i)\r\n  for 0 <= i <= n - 2\r\n\r\n# Or equivalently (the version used in the mapping code):\r\nA_i' = v_(i - 1) * (t_i - t_(i - 1))\r\n  for 1 <= i <= n - 1\r\n```\r\n\r\n\r\n\r\nSee: https://en.wikipedia.org/wiki/Riemann_sum\r\n\r\nAddresses #1400\r\n\r\nHappy to sign whatever if you decide to merge this. Thanks!"},"comment":{"url":"https://api.github.com/repos/influxdb/influxdb/issues/comments/125408615","html_url":"https://github.com/influxdb/influxdb/pull/3344#issuecomment-125408615","issue_url":"https://api.github.com/repos/influxdb/influxdb/issues/3344","id":125408615,"user":{"login":"michaelsproul","id":4452260,"avatar_url":"https://avatars.githubusercontent.com/u/4452260?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelsproul","html_url":"https://github.com/michaelsproul","followers_url":"https://api.github.com/users/michaelsproul/followers","following_url":"https://api.github.com/users/michaelsproul/following{/other_user}","gists_url":"https://api.github.com/users/michaelsproul/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelsproul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelsproul/subscriptions","organizations_url":"https://api.github.com/users/michaelsproul/orgs","repos_url":"https://api.github.com/users/michaelsproul/repos","events_url":"https://api.github.com/users/michaelsproul/events{/privacy}","received_events_url":"https://api.github.com/users/michaelsproul/received_events","type":"User","site_admin":false},"created_at":"2015-07-28T02:14:07Z","updated_at":"2015-07-28T02:14:07Z","body":"Unfortunately the same problem remains. Although I'm glad the Iterator `Next` method now returns -1 to signal the end of the iterator."}}