Skip to content

Commit

Permalink
Added tests/demos of sample().
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmyleswhite committed Jun 30, 2012
1 parent 5605347 commit c91473d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/distributions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,13 @@ d = Categorical([0.25; 0.5; 0.25])
A = zeros(Int, 10)
rand!(d, A)
@assert 1.0 <= mean(A) <= 3.0

# Examples of sample()
a = [1, 6, 19]
p = rand(Dirichlet(3))
x = sample(a, p)
@assert x == 1 || x == 6 || x == 19

a = 19.0 * eye(2)
x = sample(a)
@assert x == 0.0 || x == 19.0

0 comments on commit c91473d

Please sign in to comment.