Sha256: 28abe23cafacd40d37e8aacc1dbbdf96fb99786748e50f16ef669dea3fa8bf69
Contents?: true
Size: 1.05 KB
Versions: 8
Compression:
Stored size: 1.05 KB
Contents
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'fathom')) class Fathom::Distributions::Uniform extend Fathom::Distributions::SharedMethods class << self def rng @rng ||= GSL::Rng.alloc(GSL::Rng::MT19937_1999, Kernel.rand(100_000)) end def rand rng.ugaussian end def inverse_cdf(opts={}) mean = opts[:mean] lower = opts.fetch(:lower, true) lower = false if opts[:upper] confidence_interval = opts.fetch(:confidence_interval, 0.05) value = lower ? GSL::Cdf.ugaussian_Pinv(confidence_interval) : GSL::Cdf.ugaussian_Qinv(confidence_interval) value + mean end alias :lower_bound :inverse_cdf def upper_bound(opts={}) inverse_cdf(opts.merge(:lower => false)) end def interval_values(opts={}) confidence_interval = opts.fetch(:confidence_interval, 0.9) bound = (1 - confidence_interval) / 2.0 [lower_bound(opts.merge(:confidence_interval => bound)), upper_bound(opts.merge(:confidence_interval => bound))] end end end
Version data entries
8 entries across 8 versions & 1 rubygems