Sha256: bc13c290bd0fae5ded2f6cacfe6c1f639299cbeb495f74d488cc273de5ffa1a0
Contents?: true
Size: 602 Bytes
Versions: 3
Compression:
Stored size: 602 Bytes
Contents
require "active_support/core_ext" require "linefit" module FlexStationData class LinearRegression attr_reader :x, :y def initialize(x, y) @x = x @y = y end def slope coefficients[1] end def intercept coefficients[0] end def r_squared @r_squared ||= line_fit.rSquared rescue TypeError nil end private def coefficients @coefficients ||= line_fit.coefficients rescue TypeError [ nil, nil ] end def line_fit @line_fit ||= LineFit.new.tap { |lf| lf.setData(x, y) } end end end
Version data entries
3 entries across 3 versions & 1 rubygems