Class: Philiprehberger::MathKit::Regression::Result

Inherits:
Struct
  • Object
show all
Defined in:
lib/philiprehberger/math_kit/regression.rb

Overview

Result of a linear regression

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#interceptObject

Returns the value of attribute intercept

Returns:

  • (Object)

    the current value of intercept



8
9
10
# File 'lib/philiprehberger/math_kit/regression.rb', line 8

def intercept
  @intercept
end

#r_squaredObject

Returns the value of attribute r_squared

Returns:

  • (Object)

    the current value of r_squared



8
9
10
# File 'lib/philiprehberger/math_kit/regression.rb', line 8

def r_squared
  @r_squared
end

#slopeObject

Returns the value of attribute slope

Returns:

  • (Object)

    the current value of slope



8
9
10
# File 'lib/philiprehberger/math_kit/regression.rb', line 8

def slope
  @slope
end

Instance Method Details

#predict(x) ⇒ Float

Predict the y value for a given x

Parameters:

Returns:

  • (Float)

    the predicted y value



13
14
15
# File 'lib/philiprehberger/math_kit/regression.rb', line 13

def predict(x)
  intercept + (slope * x)
end