class Malge::ErrorFittedFunction::AExpBX32

Assumed y = a * exp(a * (x **{3/2}))

NOTE: @coefficients might become negative value.

Need discussion for dealing?

Public Instance Methods

equation() click to toggle source
# File lib/malge/errorfittedfunction/aexpbx32.rb, line 21
def equation
  sprintf("%f \* exp(%f \* x**(3.0/2.0))", * @coefficients)
end
expected_error(x) click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# File lib/malge/errorfittedfunction/aexpbx32.rb, line 39
def most_strict_pair
  @raw_pairs.max_by{ |pair| pair[0] }
end
x(y) click to toggle source

y = a * exp(a x*(3/2)) a * exp(a x*(3/2)) = y exp(a x*(3/2)) = y/a a x*(3/2) = log( y/a) x**(3/2) = log( y/a)/a x = (log( y/a)/a)**(2/3)

# File lib/malge/errorfittedfunction/aexpbx32.rb, line 35
def x(y)
  return (Math::log( y / @coefficients[0])/@coefficients[1]) ** (2.0/3.0)
end