Class: Malge::ErrorFittedFunction::AXInv

Inherits:
Malge::ErrorFittedFunction show all
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

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

#equationObject



14
15
16
# File 'lib/malge/errorfittedfunction/axinv.rb', line 14

def equation
  sprintf("%f / x", * @coefficients)
end

#expected_error(x) ⇒ Object



18
19
20
# File 'lib/malge/errorfittedfunction/axinv.rb', line 18

def expected_error(x)
  @coefficients[0] / x
end

#fitObject



8
9
10
11
12
# File 'lib/malge/errorfittedfunction/axinv.rb', line 8

def fit
  inv_pairs = Marshal.load(Marshal.dump(@diff_abs_pairs))
  inv_pairs.map! {|pair| [1.0/pair[0], pair[1]]}
  @coefficients = Malge::LeastSquare.least_square_proportional(inv_pairs)
end

#most_strict_pairObject



28
29
30
# File 'lib/malge/errorfittedfunction/axinv.rb', line 28

def most_strict_pair
  @raw_pairs.max_by{ |pair| pair[0] }
end

#x(y) ⇒ Object

y = a/x x = a/y



24
25
26
# File 'lib/malge/errorfittedfunction/axinv.rb', line 24

def x(y)
  return @coefficients[0] / y
end