https://github.com/bsm/tdigest
Implementation of Ted Dunning's t-digest in Go
https://github.com/bsm/tdigest
Last synced: about 1 year ago
JSON representation
Implementation of Ted Dunning's t-digest in Go
- Host: GitHub
- URL: https://github.com/bsm/tdigest
- Owner: bsm
- License: apache-2.0
- Created: 2020-11-13T17:01:06.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-11-13T18:27:51.000Z (over 5 years ago)
- Last Synced: 2025-04-13T05:54:50.593Z (about 1 year ago)
- Language: Go
- Size: 19.5 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tdigest
[](https://travis-ci.org/bsm/tdigest)
[](http://godoc.org/github.com/bsm/tdigest)
[](https://opensource.org/licenses/Apache-2.0)
This is an implementation of Ted Dunning's [t-digest](https://github.com/tdunning/t-digest/) in Go based
on [influxdata/tdigest](https://github.com/influxdata/tdigest).
## Example:
```go
package main
import (
"fmt"
"github.com/bsm/tdigest"
)
func main() {
// Create a new instance
t := tdigest.New()
// Add values
for _, x := range []float64{1, 2, 3, 4, 5, 5, 4, 3, 2, 1} {
t.Add(x, 1.0)
}
// Process and output
fmt.Printf("MIN : %.1f\n", t.Min())
fmt.Printf("MAX : %.1f\n", t.Max())
fmt.Printf("Q.50 : %.1f\n", t.Quantile(0.5))
fmt.Printf("Q.95 : %.1f\n", t.Quantile(0.95))
fmt.Printf("CDF(1) : %.1f\n", t.CDF(1))
fmt.Printf("CDF(2) : %.1f\n", t.CDF(2))
fmt.Printf("CDF(3) : %.1f\n", t.CDF(3))
}
```