Class: Math::Expon
Constant Summary collapse
- DEFAULT_TAU =
DEFAULT_TAU
: default exponential curvature factor for expon() 0.01
Instance Attribute Summary collapse
-
#a ⇒ Object
readonly
Returns the value of attribute a.
-
#b ⇒ Object
readonly
Returns the value of attribute b.
-
#c ⇒ Object
readonly
Returns the value of attribute c.
-
#tau ⇒ Object
readonly
Returns the value of attribute tau.
-
#y_end ⇒ Object
readonly
Returns the value of attribute y_end.
-
#y_start ⇒ Object
readonly
Returns the value of attribute y_start.
Attributes inherited from Function
Class Method Summary collapse
-
.from_yaml(yh) ⇒ Object
from_yaml(yaml_hash):.
Instance Method Summary collapse
-
#initialize(ys, ye, xs, xe, tau = DEFAULT_TAU) ⇒ Expon
constructor
Math::Expon.new(ystart, yend, xstart, xend, tau = DEFAULT_TAU):.
- #label ⇒ Object
-
#y(x) ⇒ Object
:doc:.
Methods inherited from Function
Methods included from Mext::Utilities
Constructor Details
#initialize(ys, ye, xs, xe, tau = DEFAULT_TAU) ⇒ Expon
Math::Expon.new(ystart, yend, xstart, xend, tau = DEFAULT_TAU):
exponential curve ‘y = e^(a*x + b) + c` where:
‘c = yend + tau`
Arguments are:
ystart
, yend
: start/end y values required xstart
, xend
: start/end x values tau
: the curvature factor
:nodoc:
29 30 31 32 33 34 35 36 |
# File 'lib/mext/math/expon.rb', line 29 def initialize(ys, ye, xs, xe, tau = DEFAULT_TAU) @y_start = ys @y_end = ye @x_start = xs @x_end = xe @tau = tau setup end |
Instance Attribute Details
#a ⇒ Object (readonly)
Returns the value of attribute a.
8 9 10 |
# File 'lib/mext/math/expon.rb', line 8 def a @a end |
#b ⇒ Object (readonly)
Returns the value of attribute b.
8 9 10 |
# File 'lib/mext/math/expon.rb', line 8 def b @b end |
#c ⇒ Object (readonly)
Returns the value of attribute c.
8 9 10 |
# File 'lib/mext/math/expon.rb', line 8 def c @c end |
#tau ⇒ Object (readonly)
Returns the value of attribute tau.
7 8 9 |
# File 'lib/mext/math/expon.rb', line 7 def tau @tau end |
#y_end ⇒ Object (readonly)
Returns the value of attribute y_end.
7 8 9 |
# File 'lib/mext/math/expon.rb', line 7 def y_end @y_end end |
#y_start ⇒ Object (readonly)
Returns the value of attribute y_start.
7 8 9 |
# File 'lib/mext/math/expon.rb', line 7 def y_start @y_start end |
Class Method Details
.from_yaml(yh) ⇒ Object
from_yaml(yaml_hash):
creates a Math::Expon class from a yaml file which must have the relevant fields:
x_start
x_end
y_start
y_end
tau
68 69 70 71 |
# File 'lib/mext/math/expon.rb', line 68 def from_yaml(yh) args = [yh['y_start'], yh['y_end'], yh['x_start'], yh['x_end'], yh['tau']] new(*args) end |
Instance Method Details
#label ⇒ Object
50 51 52 |
# File 'lib/mext/math/expon.rb', line 50 def label "tau: #{self.tau}" end |
#y(x) ⇒ Object
:doc:
y(x):
Returns a real value (forcing any complex result to its modulus) for any given x
:nodoc:
46 47 48 |
# File 'lib/mext/math/expon.rb', line 46 def y(x) (CMath::exp(self.a*x + self.b) + self.c).abs # we want a real number result, no complex please end |