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/maths/statistics/distributions.crConstructors
-
.new(min : Int64, max : Int64)
Create a new discrete uniform object with parameters min and man
Class Method Summary
-
.sample(min : Int, max : Int, rng : Random | Nil = nil)
Returns a random integer from min to max
-
.sample(n : Int, min : Int, max : Int, rng : Random | Nil = nil)
Returns an array of random integers from min to max
Instance Method Summary
-
#sample(rng : Random | Nil = nil) : Int
Returns a random integer from min to max
Instance methods inherited from class Statistics::DiscreteDistribution
sample(rng : Random | Nil = nil) : Intsample(n : Int32, rng : Random | Nil = nil) sample
Class methods inherited from class Statistics::DiscreteDistribution
sample(n : Int32, *args)
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(min : Int, max : Int, rng : Random | Nil = nil)
#
Returns a random integer from min to max
DiscreteUniform.sample(0, 2) # => 1
def self.sample(n : Int, min : Int, max : Int, rng : Random | Nil = nil)
#
Returns an array of random integers from min to max
DiscreteUniform.sample(4, 0, 2) # => [0, 2, 1, 1, 2]
Instance Method Detail
def sample(rng : Random | Nil = nil) : Int
#
Returns a random integer from min to max
u = DiscreteUniform.new 0, 2
u.sample # => 1