Sha256: 3325429f323aec2d7b890bdf2e976e1cd8f18391c6d6296a7617e1acd117e040
Contents?: true
Size: 1.57 KB
Versions: 5
Compression:
Stored size: 1.57 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 def coefficient_of_variation return nil unless vector vector.sd / vector.mean end alias :cov :coefficient_of_variation 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 end end
Version data entries
5 entries across 5 versions & 1 rubygems