Skip to content

Instantly share code, notes, and snippets.

@cgrand
Created January 5, 2017 14:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cgrand/7a2a5c704d44da2622701c26ecb5f9d6 to your computer and use it in GitHub Desktop.
Save cgrand/7a2a5c704d44da2622701c26ecb5f9d6 to your computer and use it in GitHub Desktop.
;; simple stats computed using xforms transducers
=> (require '[net.cgrand.xforms :as x])
=> (into {}
(x/by-key #(> % 0.5)
(x/transjuxt {:min x/min :max x/max :avg x/avg :sd x/sd}))
(repeatedly 1e6 rand))
{false
{:min 1.0036018363024368E-6,
:max 0.4999987525112054,
:avg 0.2502046186242099,
:sd 0.14452907060127915},
true
{:min 0.5000000325707634,
:max 0.9999996751822321,
:avg 0.7496015925827465,
:sd 0.1444535578897874}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment