Class: Malge::ErrorFittedFunction::AXInv4
- Inherits:
-
Malge::ErrorFittedFunction
- Object
- Malge::ErrorFittedFunction
- Malge::ErrorFittedFunction::AXInv4
- Defined in:
- lib/malge/errorfittedfunction/axinv4.rb
Overview
Assumed y = a/(x**4)
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
#count_equal_under_over, #initialize, #summary, #variance
Constructor Details
This class inherits a constructor from Malge::ErrorFittedFunction
Instance Method Details
#equation ⇒ Object
13 14 15 |
# File 'lib/malge/errorfittedfunction/axinv4.rb', line 13 def equation sprintf("%f / (x**4)", * @coefficients) end |
#expected_error(x) ⇒ Object
17 18 19 |
# File 'lib/malge/errorfittedfunction/axinv4.rb', line 17 def expected_error(x) @coefficients[0] / (x**4) end |
#fit ⇒ Object
8 9 10 11 |
# File 'lib/malge/errorfittedfunction/axinv4.rb', line 8 def fit inv_pairs = @diff_abs_pairs.map {|pair| [1.0/(pair[0]**4), pair[1]]} @coefficients = Malge::LeastSquare.least_square_proportional(inv_pairs) end |
#most_strict_pair ⇒ Object
27 28 29 |
# File 'lib/malge/errorfittedfunction/axinv4.rb', line 27 def most_strict_pair @raw_pairs.max_by{ |pair| pair[0] } end |
#x(y) ⇒ Object
y = a/x x = a/y
23 24 25 |
# File 'lib/malge/errorfittedfunction/axinv4.rb', line 23 def x(y) return (@coefficients[0] / y) ** (1.0/4.0) end |