Sha256: b396ca409e700719373b48fa6aef6575f766f936186bb92b4c9a1771f8148c63
Contents?: true
Size: 462 Bytes
Versions: 1
Compression:
Stored size: 462 Bytes
Contents
module TimeSeriesMath module LinearInterpolation include ElemwiseOperators # Returns interpolated value. # def [](t) i0, i1 = indices_at(t) return first[1] if i0.nil? return last[1] if i1.nil? k = (t - @data[i0][0]) / (@data[i1][0] - @data[i0][0]) diff_value = elemwise_sub(@data[i1][1], @data[i0][1]) elemwise_add(@data[i0][1], elemwise_mul_scalar(k, diff_value)) end end end # module TimeSeriesMath
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
time_series_math-0.1.1 | lib/time_series_math/linear_interpolation.rb |