class Statistics::DiscreteUniform

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.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class Statistics::DiscreteDistribution

sample(rng : Random | Nil = nil) : Int
sample(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

[View source]

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

[View source]
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]

[View source]

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

[View source]