Hi, I'm trying learn Clojure to see if I can use it in my simulations, and one thing I need to do is generate arrays of normally distributed numbers.
I've been able to come up with the following two ways of doing this. gaussian-matrix2 is a lot faster than gaussian-matrix1, but I'm not sure why. And it's still slower than it should be I think. Is there anything I can do to speed this up still further? Thanks, -Ranjit (import java.util.Random) (def r (Random. )) (defn next-gaussian [] (.nextGaussian r)) (defn gaussian-matrix1 [arr L] (doseq [x (range L) y (range L)] (aset arr x y (next-gaussian)))) (defn gaussian-matrix2 [L] (into-array (map double-array (partition L (repeatedly (* L L) next-gaussian))))) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en