adix/tdigest

Source   Edit  

This is a "tail digest" {github/tdunning/t-digest|arxiv.org/abs/1902.04023}. Counter decs are not possible. (So, moving quantiles are unsupported.) In my experiments, quantiles are 5X slower than adix/lghisto. Tail quantiles do deliver better accuracy for less space (but lghisto already needs little local cache space | network BW in absolute terms). There may be a way to adapt my B-Tree to speed up the idea. { tDig is also very involved - folks just intuit histo(ln(x)), but that is a more subjective critique. }

Types

DigesT = object
  scale*: Scale              ## What scale function to use
Source   Edit  
Group = object
  m*: float                  ## mean
  w*: int                    ## weight
Group/Cluster/Centroid Source   Edit  
Scale = enum
  scLog                      ## Other scales possible, but unimpl here
Source   Edit  

Procs

func add(s: var DigesT; others: var openArray[DigesT]) {....raises: [ValueError],
    tags: [], forbids: [].}
Source   Edit  
func add(s: var DigesT; x: float; w = 1) {....raises: [ValueError], tags: [],
    forbids: [].}
Main update API Source   Edit  
func cdf(s: var DigesT; x: float): float {....raises: [], tags: [], forbids: [].}
Source   Edit  
func compress(s: var DigesT) {....raises: [], tags: [], forbids: [].}
best done only when we want to show results to the outside world. Source   Edit  
func init(s: var DigesT; cpr = 100.0; scale = scLog; mainLen = 0; nBuf = 0) {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
func initDigesT(cpr = 100.0; scale = scLog; mainLen = 0; nBuf = 0): DigesT {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
func mergeNew(s: var DigesT; force = false; cpr = -1.0) {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
func quantile(s: var DigesT; q: float): float {....raises: [ValueError], tags: [],
    forbids: [].}
Source   Edit  
func space(s: DigesT): int {....raises: [], tags: [], forbids: [].}
Source   Edit  
func weight(s: DigesT): int {....raises: [], tags: [], forbids: [].}
total count represented Source   Edit  

Iterators

iterator groups(s: DigesT): Group {....raises: [], tags: [], forbids: [].}
Source   Edit