1.2.3-SNAPSHOT

- (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

© incanter
See http://incanter.org for copyright and license details.

(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)))

© incanter
See http://incanter.org for copyright and license details.

Used in 0 other vars

## Comments top

## No comments for

integer-distribution. Log in to add a comment.