(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.
Source
(defn random-sample
"Returns items from coll with random probability of prob (0.0 -
1.0). Returns a transducer when no collection is provided."
{:added "1.7"}
([prob]
(filter (fn [_] (< (rand) prob))))
([prob coll]
(filter (fn [_] (< (rand) prob)) coll)))