Permalink
Browse files

Merge pull request #71 from nybbles/master

Fix for sample-multinomial with size 1 resulting in ISeq from Double exception
  • Loading branch information...
2 parents 7c6878a + 7214006 commit bd6315b2e4ca0613a60c94044b6247bf07f10e10 @alexott alexott committed Mar 19, 2012
Showing with 4 additions and 8 deletions.
  1. +4 −8 modules/incanter-core/src/incanter/stats.clj
@@ -427,13 +427,9 @@
(let [min-val (double min)
max-val (double max)
dist (DoubleUniform. min-val max-val (DoubleMersenneTwister.))]
- (if (= size 1)
- (if integers
- (DoubleUniform/staticNextIntFromTo min-val max-val)
- (DoubleUniform/staticNextDoubleFromTo min-val max-val))
- (if integers
- (for [_ (range size)] (DoubleUniform/staticNextIntFromTo min-val max-val))
- (for [_ (range size)] (DoubleUniform/staticNextDoubleFromTo min-val max-val)))))))
+ (if integers
+ (for [_ (range size)] (DoubleUniform/staticNextIntFromTo min-val max-val))
+ (for [_ (range size)] (DoubleUniform/staticNextDoubleFromTo min-val max-val))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1699,7 +1695,7 @@
(loop [samp-indices [] indices-set #{}]
(if (= (count samp-indices) size)
samp-indices
- (let [i (sample-uniform 1 :min 0 :max max-idx :integers true)]
+ (let [i (first (sample-uniform 1 :min 0 :max max-idx :integers true))]
(if (contains? indices-set i)
(recur samp-indices indices-set)
(recur (conj samp-indices i) (conj indices-set i))))))))))))

0 comments on commit bd6315b

Please sign in to comment.