# [Random](Random) provides an interface to Ruby's # pseudo-random number generator, or PRNG. The PRNG produces a # deterministic sequence of bits which approximate true randomness. The # sequence may be represented by integers, floats, or binary strings. # # The generator may be initialized with either a system-generated or # user-supplied seed value by using # [::srand](Random#method-c-srand). # # The class method [\#rand](Random#method-i-rand) # provides the base functionality of # [Kernel\#rand](https://ruby-doc.org/core-2.6.3/Kernel.html#method-i-rand) # along with better handling of floating point values. These are both # interfaces to Random::DEFAULT, the Ruby system PRNG. # # [::new](Random#method-c-new) will create a new PRNG # with a state independent of Random::DEFAULT, allowing multiple # generators with different seed values or sequence positions to exist # simultaneously. [Random](Random) objects can be # marshaled, allowing sequences to be saved and resumed. # # PRNGs are currently implemented as a modified Mersenne Twister with a # period of 2\*\*19937-1. class Random < Object include Random::Formatter def ==: (untyped arg0) -> bool def bytes: (Integer size) -> String def initialize: (?Integer seed) -> void def rand: () -> Float | (Integer | ::Range[Integer] max) -> Integer | (Float | ::Range[Float] max) -> Float # Returns the seed value used to initialize the generator. This may be # used to initialize another generator with the same state at a later # time, causing it to produce the same sequence of numbers. # # ```ruby # prng1 = Random.new(1234) # prng1.seed #=> 1234 # prng1.rand(100) #=> 47 # # prng2 = Random.new(prng1.seed) # prng2.rand(100) #=> 47 # ``` def seed: () -> Integer # Returns an arbitrary seed value. This is used by # [::new](Random.downloaded.ruby_doc#method-c-new) when no seed value is # specified as an argument. # # ```ruby # Random.new_seed #=> 115032730400174366788466674494640623225 # ``` def self.new_seed: () -> Integer def self.rand: (?Integer max) -> Numeric def self.srand: (?Integer number) -> Numeric end Random::DEFAULT: Random module Random::Formatter def base64: (?Integer? n) -> String def hex: (?Integer? n) -> String def rand: () -> Float | (?Float? n) -> Float | (?Integer? n) -> Integer | (?Numeric? n) -> Numeric | (?::Range[Float]? n) -> Float | (?::Range[Integer]? n) -> Integer | (?::Range[Numeric]? n) -> Numeric def random_bytes: (?Integer? n) -> String def random_number: () -> Float | (?Float? n) -> Float | (?Integer? n) -> Integer | (?Numeric? n) -> Numeric | (?::Range[Float]? n) -> Float | (?::Range[Integer]? n) -> Integer | (?::Range[Numeric]? n) -> Numeric def urlsafe_base64: (?Integer? n, ?bool padding) -> String def uuid: () -> String end