Class: ERV::GammaDistribution
- Inherits:
-
Distribution
- Object
- Distribution
- ERV::GammaDistribution
- Defined in:
- lib/erv/gamma_distribution.rb
Instance Method Summary collapse
-
#initialize(opts) ⇒ GammaDistribution
constructor
A new instance of GammaDistribution.
Constructor Details
#initialize(opts) ⇒ GammaDistribution
Returns a new instance of GammaDistribution.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/erv/gamma_distribution.rb', line 12 def initialize(opts) super(opts) raise ArgumentError unless opts[:rate] and opts[:shape] scale = 1 / opts[:rate].to_f shape = opts[:shape].to_f if RUBY_PLATFORM == 'java' # create distribution d = JGammaDistribution.new(@rng, shape, scale, JGammaDistribution::DEFAULT_INVERSE_ABSOLUTE_ACCURACY) # setup sampling function @func = Proc.new { d.sample } else # setup sampling function @func = Proc.new { @rng.gamma(shape, scale) } end end |