Discrete

Function for generating values from discrete uniform distributions

Interface

discrete (a:int, b:int) : int

where a⇐b. Returns a drawing from a discrete uniform distribution between a and b (a and b included).

Raises Discrete exception, if a>b.

Characteristics

Mean: (a+b)/2

Variance: ((b-a+1)^2-1)/12

Probability mass functions for discrete uniform distributions:

Probability mass functions for discrete uniform distributions

Example

discrete(1,6)

Throwing a die has a discrete uniform distribution with parameters a=1 and b=6. The function discrete will then return the number of eyes on the die.

Related pages