data-science

danielneal 2026-05-21T16:04:53.819949Z

Hey quick question - if I want to draw samples from e.g. a gamma, or gaussian distribution, what’s a good, fast clojure (or java) lib to use?

Harold 2026-05-21T16:32:29.394759Z

https://generateme.github.io/fastmath/fastmath.random.html

user> (def _ (add-lib 'org.scicloj/noj))
#'user/_
user> (require '[fastmath.random :as r])
nil
user> (take 10 (r/sequence-generator :gaussian 1))
(-0.1547736360816925
 1.8051191792904466
 -0.20709054853216552
 0.5171728760064104
 0.2498853318740287
 0.5562857017358865
 0.8022862755958767
 0.251129872734826
 -0.5441381558262343
 -0.14407141024181996)
user> (r/->seq (r/distribution :gamma) 10)
(5.799961441228679
 5.896788029044922
 1.683425787924847
 6.806011683813666
 2.6057208109240175
 7.701674091635153
 5.631465984279382
 1.401760757867204
 5.219105035951475
 0.7030695884782802)

Harold 2026-05-21T16:33:05.610729Z

^ @daslu @tsulej - check my work. πŸ™‚

πŸ‘ 1
☝️ 1
✨ 1
Daniel Slutsky 2026-05-21T16:55:51.965949Z

Nice! ✨ I'd just add that it is recommended to use Fastmath version 3 (even though it is marked as "alpha", the relevant parts are stable). https://clojars.org/generateme/fastmath Here is the documentation for version 3: https://generateme.github.io/fastmath/clay/ The fabulous fastmath.random documentation is BTW thanks to the work of @mavbozo, who adapted the version 2 docs some time ago. https://generateme.github.io/fastmath/clay/random.html

πŸ™‡ 1
danielneal 2026-05-21T17:36:20.612719Z

Ooh brilliant thanks so much!