Class: Malge::ErrorFittedFunction::AExpBX32
- Inherits:
-
Malge::ErrorFittedFunction
- Object
- Malge::ErrorFittedFunction
- Malge::ErrorFittedFunction::AExpBX32
- Defined in:
- lib/malge/errorfittedfunction/aexpbx32.rb
Overview
Assumed y = a * exp(a * (x **3/2))
NOTE: @coefficients might become negative value. Need discussion for dealing?
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
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
21 22 23 |
# File 'lib/malge/errorfittedfunction/aexpbx32.rb', line 21 def equation sprintf("%f \* exp(%f \* x**(3.0/2.0))", * @coefficients) end |
#expected_error(x) ⇒ Object
25 26 27 |
# File 'lib/malge/errorfittedfunction/aexpbx32.rb', line 25 def expected_error(x) @coefficients[0] * Math::exp( @coefficients[1] * x **(3.0/2.0)) end |
#fit ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/malge/errorfittedfunction/aexpbx32.rb', line 10 def fit inv_pairs = @diff_abs_pairs.map {|pair| x = pair[0] ** (3.0/2.0) y = Math::log(pair[1]) [x,y] } inv_pairs.delete_if {|pair| ! pair[1].finite?} @coefficients = Malge::LeastSquare.least_square_1st_degree(inv_pairs) @coefficients[0] = Math::exp @coefficients[0] end |
#most_strict_pair ⇒ Object
39 40 41 |
# File 'lib/malge/errorfittedfunction/aexpbx32.rb', line 39 def most_strict_pair @raw_pairs.max_by{ |pair| pair[0] } end |
#x(y) ⇒ Object
35 36 37 |
# File 'lib/malge/errorfittedfunction/aexpbx32.rb', line 35 def x(y) return (Math::log( y / @coefficients[0])/@coefficients[1]) **(2.0/3.0) end |