File: README.md

package info (click to toggle)
golang-github-influxdata-tdigest 0.0~git20180711.a7d76c6-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 140 kB
  • sloc: cpp: 509; sh: 9; makefile: 4
file content (42 lines) | stat: -rw-r--r-- 1,004 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# tdigest

This is an implementation of Ted Dunning's [t-digest](https://github.com/tdunning/t-digest/) in Go.

The implementaion is based off [Derrick Burns' C++ implementation](https://github.com/derrickburns/tdigest).

## Example

```go
package main

import (
	"log"

	"github.com/influxdata/tdigest"
)

func main() {
	td := tdigest.NewWithCompression(1000)
	for _, x := range []float64{1, 2, 3, 4, 5, 5, 4, 3, 2, 1} {
		td.Add(x, 1)
	}

	// Compute Quantiles
	log.Println("50th", td.Quantile(0.5))
	log.Println("75th", td.Quantile(0.75))
	log.Println("90th", td.Quantile(0.9))
	log.Println("99th", td.Quantile(0.99))

	// Compute CDFs
	log.Println("CDF(1) = ", td.CDF(1))
	log.Println("CDF(2) = ", td.CDF(2))
	log.Println("CDF(3) = ", td.CDF(3))
	log.Println("CDF(4) = ", td.CDF(4))
	log.Println("CDF(5) = ", td.CDF(5))
}
```

## TODO

Only the methods for a single TDigest have been implemented.
The methods to merge two or more existing t-digests into a single t-digest have yet to be implemented.