Skip to content

Instantly share code, notes, and snippets.

@AlexAti
Created October 6, 2015 20:22
Show Gist options
  • Save AlexAti/53dcb3ad9ff0f94843f7 to your computer and use it in GitHub Desktop.
Save AlexAti/53dcb3ad9ff0f94843f7 to your computer and use it in GitHub Desktop.
Question: How many elements of a population do I get with n samples of size s?
(defn coverage-in-n-samples [samples size population]
"Question: How many elements of a population do I get with n samples of size s?"
(let [pop (range 0 population)]
(->> (range 0 samples)
(map (fn [dumb] (take size (shuffle pop))))
(doall)
(flatten)
(distinct)
(count)
(* (/ 1.0 population)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment