function | since v0.0-2301 | clojure.core/random-sample | Edit |
(random-sample prob)
(random-sample prob coll)
Returns items from coll with random probability of prob (0.0 - 1.0). Returns a transducer when no collection is provided.
(defn random-sample
([prob]
(filter (fn [_] (< (rand) prob))))
([prob coll]
(filter (fn [_] (< (rand) prob)) coll)))