# ClojureDocs(beta)

## incanter

### Namespaces

• incanter

1.2.3-SNAPSHOT permalink

# integer-distribution

## incanter.distributions

• (integer-distribution)
• (integer-distribution end)
• (integer-distribution start end)

Create a uniform distribution over a set of integers over
the (start, end] interval. An alternative method of creating
a distribution would be to just use a sequence of integers
(e.g. (draw (range 100000))). For large sequences, like the one
in the example, using a sequence will be require realizing the
entire sequence before a draw can be taken. This less efficient than
computing random draws based on the end points of the distribution.

Arguments:
start The lowest end of the interval, such that (>= (draw d) start)
is always true. (Default 0)
end The value at the upper end of the interval, such that
(> end (draw d)) is always true. Note the strict inequality.
(Default 1)

See also:
pdf, cdf, draw, support

References:
http://en.wikipedia.org/wiki/Uniform_distribution_(discrete)

Examples:
(pdf (integer-distribution 0 10) 3) ; returns 1/10 for any value
(draw (integer-distribution -5 5))
(draw (integer-distribution (bit-shift-left 2 1000))) ; probably a very large value

### 0 Examples top

Log in to add / edit an example.

### See Also top

Log in to add a see also.

### Source incanter/distributions.clj:172 top

```(defn integer-distribution
"
Create a uniform distribution over a set of integers over
the (start, end] interval. An alternative method of creating
a distribution would be to just use a sequence of integers
(e.g. (draw (range 100000))). For large sequences, like the one
in the example, using a sequence will be require realizing the
entire sequence before a draw can be taken. This less efficient than
computing random draws based on the end points of the distribution.

Arguments:
start	The lowest end of the interval, such that (>= (draw d) start)
is always true. (Default 0)
end		The value at the upper end of the interval, such that
(> end (draw d)) is always true. Note the strict inequality.
(Default 1)

See also:
pdf, cdf, draw, support

References:
http://en.wikipedia.org/wiki/Uniform_distribution_(discrete)

Examples:
(pdf (integer-distribution 0 10) 3) ; returns 1/10 for any value
(draw (integer-distribution -5 5))
(draw (integer-distribution (bit-shift-left 2 1000))) ; probably a very large value
"
([] (integer-distribution 0 1))
([end] (integer-distribution 0 end))
([start end]
(assert (> end start))
(UniformInt. start end)))```
Vars in incanter.distributions/integer-distribution: > assert defn
Used in 0 other vars