class Malge::ErrorFittedFunction::AExpBX
NOTE: @coefficients might become negative value.
Need discussion for dealing?
NOTE: Zero value for |y - y_last| is simply ignored due to impossible log evaluation.
Public Instance Methods
equation()
click to toggle source
# File lib/malge/errorfittedfunction/aexpbx.rb, line 24 def equation sprintf("%f \* exp(%f \* x)", * @coefficients) end
expected_error(x)
click to toggle source
# File lib/malge/errorfittedfunction/aexpbx.rb, line 28 def expected_error(x) @coefficients[0] * Math::exp( @coefficients[1] * x) end
fit()
click to toggle source
# File lib/malge/errorfittedfunction/aexpbx.rb, line 13 def fit inv_pairs = @diff_abs_pairs.map {|pair| x = pair[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()
click to toggle source
# File lib/malge/errorfittedfunction/aexpbx.rb, line 41 def most_strict_pair @raw_pairs.max_by{ |pair| pair[0] } end