Module: Fathom::NumericMethods
- Included in:
- DataNode, PlausibleRange
- Defined in:
- lib/fathom/node/node_extensions/numeric_methods.rb
Instance Method Summary collapse
- #coefficient_of_variation ⇒ Object (also: #cov)
- #initialize(opts = {}) ⇒ Object
- #interval_values(opts = {}) ⇒ Object
- #inverse_cdf(opts = {}) ⇒ Object (also: #lower_bound)
- #mean ⇒ Object
- #rand ⇒ Object
- #standard_deviation ⇒ Object (also: #std, #sd)
- #summary ⇒ Object
- #upper_bound(opts = {}) ⇒ Object
- #vector ⇒ Object
Instance Method Details
#coefficient_of_variation ⇒ Object Also known as: cov
49 50 51 52 |
# File 'lib/fathom/node/node_extensions/numeric_methods.rb', line 49 def coefficient_of_variation return nil unless vector vector.sd / vector.mean end |
#initialize(opts = {}) ⇒ Object
4 5 6 |
# File 'lib/fathom/node/node_extensions/numeric_methods.rb', line 4 def initialize(opts={}) super(opts) end |
#interval_values(opts = {}) ⇒ Object
45 46 47 |
# File 'lib/fathom/node/node_extensions/numeric_methods.rb', line 45 def interval_values(opts={}) distribution.interval_values(opts.merge(:mean => mean, :sd => sd)) end |
#inverse_cdf(opts = {}) ⇒ Object Also known as: lower_bound
36 37 38 |
# File 'lib/fathom/node/node_extensions/numeric_methods.rb', line 36 def inverse_cdf(opts={}) distribution.inverse_cdf(opts.merge(:mean => mean, :sd => sd)) end |
#mean ⇒ Object
31 32 33 34 |
# File 'lib/fathom/node/node_extensions/numeric_methods.rb', line 31 def mean return nil unless vector vector.mean end |
#rand ⇒ Object
8 9 10 11 |
# File 'lib/fathom/node/node_extensions/numeric_methods.rb', line 8 def rand return nil unless vector distribution.rand(sd) + mean end |
#standard_deviation ⇒ Object Also known as: std, sd
24 25 26 27 |
# File 'lib/fathom/node/node_extensions/numeric_methods.rb', line 24 def standard_deviation return nil unless vector vector.sd end |
#summary ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/fathom/node/node_extensions/numeric_methods.rb', line 55 def summary { :mean => mean, :standard_deviation => standard_deviation, :min => vector ? vector.min : nil, :max => vector ? vector.max : nil, :lower_bound => lower_bound, :upper_bound => upper_bound, :coefficient_of_variation => coefficient_of_variation } end |
#upper_bound(opts = {}) ⇒ Object
41 42 43 |
# File 'lib/fathom/node/node_extensions/numeric_methods.rb', line 41 def upper_bound(opts={}) distribution.upper_bound(opts.merge(:mean => mean, :sd => sd)) end |
#vector ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fathom/node/node_extensions/numeric_methods.rb', line 13 def vector return @vector if @vector return nil unless values case values when Array @vector = GSL::Vector.ary_to_gv(values) when GSL::Vector @vector = values end end |