Awesome
t-digest
A Clojure(Script) library for on-line accumulation of rank-based statistics using the t-digest.
Documentation
You can view the documentation here.
Installation
Add the following dependency:
[t-digest "0.1.0"]
Usage
The histogram maintains an approximation of the values which have been inserted into it. At any point you can query the histogram for statistics about values accumulated so far, such as the median or the IQR:
(require '[t-digest.core :as t])
(def histogram
(-> (t/create)
(t/insert 5)
(t/insert 2)
(t/insert 1)
(t/insert 4)
(t/insert 3)))
(t/median histogram) ;;=> 3.0
(t/iqr histogram) ;; => 2.0
The trade-off between accuracy and size is controlled by a single compression parameter. This can be passed when the histogram is created:
(t/create {:compression 100})
The default value is 100. 1000 would be very large. See the t-digest paper for more information.
License
Copyright © 2016 Henry Garner
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.