TimeSeriesMath
Time series data structures and functions.
Installation
Add this line to your application's Gemfile:
gem 'time_series_math'
And then execute:
$ bundle
Or install it yourself as:
$ gem install time_series_math
Usage
TimeSeries
TimeSeries
class is a data structure for storing timestamped values.
TimeSeries maintains order of its elements and provides efficient search methods
for near-constant time access
(depends strongly on timestamps distribution -- the more even, the better).
Examples:
require 'time_series_math'
include TimeSeriesMath
ts = TimeSeries.new
ts.push 1.0, { x: 2.0, y: 3.0 }
ts.push 1.2, { x: 2.0, y: 3.0 }
ts.push 1.6, { x: 2.0, y: 3.0 }
ts.push 1.9, { x: 2.0, y: 3.0 }
ts.push 2.1, { x: 2.0, y: 3.0 }
ts[2.3] = { x: 2.5, y: 3.5 }
ts[2.5] = { x: 2.2, y: 3.7 }
ts = TimeSeries.new
tt = [ 1.0, 1.2, 1.6, 1.9, 2.1 ]
dd = [ {x: 2.0}, {x: 2.1}, {x: 2.5}, {x: 2.7}, {x: 2.85} ]
ts.push_array(tt, dd)
ts[1.2]
ts[2.095]
Contributing
- Fork it ( https://github.com/kukushkin/time_series_math/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request