Sha256: 408e0ac65bee51744aa587bd3223cd72442c114a307618b3ee344713cb40d766

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'fathom'))
module Fathom  
  module NumericMethods
    def initialize(opts={})
      super(opts)
    end
    
    def rand
      return nil unless vector
      distribution.rand(sd) + mean
    end
    
    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
    
    def standard_deviation
      return nil unless vector
      vector.sd
    end
    alias :std :standard_deviation
    alias :sd :standard_deviation

    def mean
      return nil unless vector
      vector.mean
    end
    
    def inverse_cdf(opts={})
      distribution.inverse_cdf(opts.merge(:mean => mean, :sd => sd))
    end
    alias :lower_bound :inverse_cdf

    def upper_bound(opts={})
      distribution.upper_bound(opts.merge(:mean => mean, :sd => sd))
    end

    def interval_values(opts={})
      distribution.interval_values(opts.merge(:mean => mean, :sd => sd))
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fathom-0.3.0 lib/fathom/numeric_methods.rb
fathom-0.2.3 lib/fathom/numeric_methods.rb