class Statistics::DiscreteUniform
- Statistics::DiscreteUniform
- Statistics::DiscreteDistribution
- Reference
- Object
Overview
A symmetric probability distribution whereby a finite number of values are equally likely to be observed: every one of n values has equal probability 1/n.
Defined in:
gsl/base/statistics.crConstructors
-
.new(min : Int64, max : Int64)
Create a new discrete uniform object with parameters min and man
Class Method Summary
-
.sample(n : Int, min : Int, max : Int)
Returns an array of random integers from min to max
-
.sample(min : Int, max : Int)
Returns a random integer from min to max
Instance Method Summary
-
#sample : Int
Returns a random integer from min to max
Instance methods inherited from class Statistics::DiscreteDistribution
sample : Int
sample
Constructor Detail
def self.new(min : Int64, max : Int64)
#
Create a new discrete uniform object with parameters min and man
u = DiscreteUniform.new 0, 2
Class Method Detail
def self.sample(n : Int, min : Int, max : Int)
#
Returns an array of random integers from min to max
DiscreteUniform.sample(4, 0, 2) # => [0, 2, 1, 1, 2]
def self.sample(min : Int, max : Int)
#
Returns a random integer from min to max
DiscreteUniform.sample(0, 2) # => 1
Instance Method Detail
def sample : Int
#
Returns a random integer from min to max
u = DiscreteUniform.new 0, 2
u.sample # => 1