Sha256: a730ff0e83afc44e22f16ca33c54a4aecbe62f189e19648ff4a9667cce80d398
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'fathom')) =begin A DataNode is a node generated from data itself. It stores the data and reveals some statistical measurements for the data. It expects an array or vector of values and generates a vector on demans. =end class Fathom::DataNode include NodeUtilities attr_reader :values, :name, :distribution, :confidence_interval def initialize(opts={}) @values = opts[:values] raise ArgumentError, "Must provided values: DataNode.new(:values => [...])" unless self.values @name = opts[:name] @distribution = opts[:distribution] end alias :ci :confidence_interval def vector @vector ||= GSL::Vector.ary_to_gv(self.values) end def standard_deviation @standard_deviation ||= vector.sd end alias :sd :standard_deviation alias :std :standard_deviation def mean @mean ||= vector.mean end def rand rng.gaussian(std) + mean end protected def rng @rng ||= GSL::Rng.alloc(GSL::Rng::MT19937_1999, Kernel.rand(100_000)) end end if __FILE__ == $0 include Fathom # TODO: Is there anything you want to do to run this file on its own? # DataNode.new end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fathom-0.2.2 | lib/fathom/data_node.rb |
fathom-0.2.1 | lib/fathom/data_node.rb |