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/base/statistics.cr

Constructors

Class Method Summary

Instance Method Summary

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

[View source]

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]

[View source]
def self.sample(min : Int, max : Int) #

Returns a random integer from min to max

DiscreteUniform.sample(0, 2) # => 1

[View source]

Instance Method Detail

def sample : Int #

Returns a random integer from min to max

u = DiscreteUniform.new 0, 2
u.sample # => 1

[View source]