class Fathom::Variable

Public Class Methods

infer(obj) click to toggle source
# File lib/fathom/data/variable.rb, line 8
def infer(obj)
  case obj
  when Variable
    obj
  when Hash
    new(obj)
  when Symbol, String
    new(:name => obj)
  end
end
new(attrs={}) click to toggle source
# File lib/fathom/data/variable.rb, line 35
def initialize(attrs={})
  attrs[:id] ||= UUID.generate
  @attributes = attrs
  self.prior_odds ||= uniform_set.dup
end

Public Instance Methods

==(other)
Alias for: eql
eql(other) click to toggle source
# File lib/fathom/data/variable.rb, line 45
def eql(other)
  return false unless other.is_a?(Variable)
  self.name == other.name
end
Also aliased as: ==
underscored_name() click to toggle source
# File lib/fathom/data/variable.rb, line 41
def underscored_name
  name.to_s.gsub(/\W/, "_").underscore
end

Protected Instance Methods

uniform_set() click to toggle source
# File lib/fathom/data/variable.rb, line 52
def uniform_set
  size = self.outcomes.size
  Array.new(size, 1/size.to_f)
end