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