HTTPS SSH
clj-sample-utils ================ Description ----------- A [Clojure](http://clojure.org/) library for probability sampling. Inspired by the functions `sample` and `sample.int` in [the R language](http://www.r-project.org/). See: <http://bitbucket.org/mnacamura/clj-sample-utils/> Example ------- user=> (use 'sample-utils) nil user=> (take 10 (sample [:a :b :c])) (:c :c :a :b :c :c :a :a :a :b) user=> (take 10 (sample [:a :b :c] :prob [0 1 2])) (:c :c :c :c :c :b :c :c :b :b) user=> (frequencies (take 100000 (sample [:a :b :c] :prob [0 1 2]))) {:b 33238, :c 66762} user=> (take 10 (sample [:a :b :c] :prob {:b 2 :c 1})) (:c :c :b :b :b :b :b :c :b :c) user=> (take 10 (sample [:a :b :c] :replace? false)) (:b :a :c) You can also use a Mersenne Twister random number generator provided by [Sean Luke](http://www.cs.gmu.edu/~sean/research/). user=> (use '[ec.util.mtf :only (make-mtf-gen)]) nil user=> (require '[sample-utils.mtf :as mtf]) nil user=> (def g (make-mtf-gen)) #'user/g user=> (take 10 (mtf/sample g [:a :b :c])) (:a :b :c :b :a :c :a :c :b :a) Installation ------------ Add the dependency to your `project.clj` (in case you use [Leiningen](http://github.com/technomancy/leiningen/) or [Cake](http://github.com/ninjudd/cake/)): [clj-sample-utils "0.0.1"] Then, (use 'sample-utils) or, ;; This contains the high-performance but unsafe version. (use 'sample-utils.unsafe) ;; With a Mersenne Twister random number generator. (use 'sample-utils.mtf) ;; The unsafe version with a Mersenne Twister random number generator. (use 'sample-utils.mtf.unsafe) Build from source ----------------- 1. Download `MersenneTwisterFast.java` from [Sean Luke's website](http://www.cs.gmu.edu/~sean/research/). 2. Put `MersenneTwisterFast.java` into `src/jvm/ec/util/`. 3. Execute: cake jar ; in case you use Cake lein jar ; in case you use Leiningen Contact ------- Mitsuhiro Nakamura <m.nacamura@gmail.com> License ------- Eclipse Public License - v 1.0, see LICENSE.