Sha256: b260e129465d8d810dd8a9e6b09687b3a96ff44a16b9d4bc55418c45b982192d

Contents?: true

Size: 401 Bytes

Versions: 2

Compression:

Stored size: 401 Bytes

Contents

# frozen_string_literal: true

#
# Mersenne Twister algorithm to sample from Uniform distribution
# See: https://en.wikipedia.org/wiki/Mersenne_Twister
#
# This implementation uses Random class of Ruby core.
# See: http://ruby-doc.org/core-2.5.0/Random.html
#
class Distrb::Uniform::MersenneTwister
  def initialize
    @random = Random.new
  end

  def sample *args
    @random.rand(*args)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
distrb-0.1.1 lib/distrb/uniform/mersenne_twister.rb
distrb-0.1.0 lib/distrb/uniform/mersenne_twister.rb