Class: Malge::ErrorFittedFunction::AXInv
- Inherits:
-
Malge::ErrorFittedFunction
- Object
- Malge::ErrorFittedFunction
- Malge::ErrorFittedFunction::AXInv
- Defined in:
- lib/malge/errorfittedfunction/axinv.rb
Overview
Assumed y = a/x
Instance Attribute Summary
Attributes inherited from Malge::ErrorFittedFunction
#coefficients, #diff_abs_pairs, #raw_pairs
Instance Method Summary collapse
- #equation ⇒ Object
- #expected_error(x) ⇒ Object
- #fit ⇒ Object
- #most_strict_pair ⇒ Object
-
#x(y) ⇒ Object
y = a/x x = a/y.
Methods inherited from Malge::ErrorFittedFunction
Constructor Details
This class inherits a constructor from Malge::ErrorFittedFunction
Instance Method Details
#equation ⇒ Object
15 16 17 |
# File 'lib/malge/errorfittedfunction/axinv.rb', line 15 def equation sprintf("f(x) = %f / x", * @coefficients) end |
#expected_error(x) ⇒ Object
19 20 21 |
# File 'lib/malge/errorfittedfunction/axinv.rb', line 19 def expected_error(x) @coefficients[0] / x end |
#fit ⇒ Object
8 9 10 11 12 13 |
# File 'lib/malge/errorfittedfunction/axinv.rb', line 8 def fit inv_pairs = Marshal.load(Marshal.dump(@diff_abs_pairs)) #inv_pairs.delete([most_strict_x, 0.0]) inv_pairs.map! {|pair| [1.0/pair[0], pair[1]]} @coefficients = Malge::LeastSquare.least_square_proportional(inv_pairs) end |
#most_strict_pair ⇒ Object
29 30 31 |
# File 'lib/malge/errorfittedfunction/axinv.rb', line 29 def most_strict_pair @raw_pairs.max_by{ |pair| pair[0] } end |
#x(y) ⇒ Object
y = a/x x = a/y
25 26 27 |
# File 'lib/malge/errorfittedfunction/axinv.rb', line 25 def x(y) return @coefficients[0] / y end |