Class: Loess::Interpolator
- Inherits:
-
Object
- Object
- Loess::Interpolator
- Defined in:
- lib/loess.rb
Constant Summary collapse
- DEFAULT_ACCURACY =
Sane Defaults as per Apache
1e-12- DEFAULT_BANDWIDTH =
A sensible value is usually 0.25 to 0.5
0.3- DEFAULT_ROBUSTNESS_FACTOR =
number of iterations to refine over 1 or 2 is usually good enough
2
Instance Attribute Summary collapse
-
#accuracy ⇒ Object
Returns the value of attribute accuracy.
-
#bandwidth ⇒ Object
Returns the value of attribute bandwidth.
-
#data ⇒ Object
Returns the value of attribute data.
-
#robustness_factor ⇒ Object
Returns the value of attribute robustness_factor.
Class Method Summary collapse
-
.interpolate(data, options = {}) ⇒ Object
Accepts array of [x, y] pairs e.g.
Instance Method Summary collapse
-
#initialize(data = [], options = {}) ⇒ Interpolator
constructor
data: Accepts array of [x, y] pairs e.g.
-
#interpolate(data = nil) ⇒ Object
Accepts array of [x, y] pairs e.g.
-
#spline_interpolator(data = nil) ⇒ Object
Accepts array of [x, y] pairs e.g.
Constructor Details
#initialize(data = [], options = {}) ⇒ Interpolator
data: Accepts array of [x, y] pairs e.g. [ [1, 2], [3, 4], [5, 6], [0, 42] ] For options, refer to defaults above
16 17 18 19 20 21 22 23 |
# File 'lib/loess.rb', line 16 def initialize(data = [], = {}) @xval, @yval = split_up(data) self.accuracy = Float([:accuracy] || DEFAULT_ACCURACY) self.bandwidth = Float([:bandwidth] || DEFAULT_BANDWIDTH) self.robustness_factor = Integer([:robustness_factor] || DEFAULT_ROBUSTNESS_FACTOR) @klass = Rjb::import('org.apache.commons.math3.analysis.interpolation.LoessInterpolator') @interpolator = @klass.new(bandwidth, robustness_factor, accuracy) end |
Instance Attribute Details
#accuracy ⇒ Object
Returns the value of attribute accuracy.
7 8 9 |
# File 'lib/loess.rb', line 7 def accuracy @accuracy end |
#bandwidth ⇒ Object
Returns the value of attribute bandwidth.
7 8 9 |
# File 'lib/loess.rb', line 7 def bandwidth @bandwidth end |
#data ⇒ Object
Returns the value of attribute data.
7 8 9 |
# File 'lib/loess.rb', line 7 def data @data end |
#robustness_factor ⇒ Object
Returns the value of attribute robustness_factor.
7 8 9 |
# File 'lib/loess.rb', line 7 def robustness_factor @robustness_factor end |
Class Method Details
.interpolate(data, options = {}) ⇒ Object
Accepts array of [x, y] pairs e.g. [ [1, 2], [3, 4], [5, 6], [0, 42] ]
41 42 43 |
# File 'lib/loess.rb', line 41 def self.interpolate(data, = {}) new(data, ).interpolate end |
Instance Method Details
#interpolate(data = nil) ⇒ Object
Accepts array of [x, y] pairs e.g. [ [1, 2], [3, 4], [5, 6], [0, 42] ]
27 28 29 30 |
# File 'lib/loess.rb', line 27 def interpolate(data = nil) @xval, @yval = split_up(data) if data @interpolator.smooth(@xval, @yval) end |
#spline_interpolator(data = nil) ⇒ Object
Accepts array of [x, y] pairs e.g. [ [1, 2], [3, 4], [5, 6], [0, 42] ]
34 35 36 37 |
# File 'lib/loess.rb', line 34 def spline_interpolator(data = nil) @xval, @yval = split_up(data) if data @interpolator.interpolator(@xval, smooth(@xval, @yval)) end |