Categorygithub.com/zeebo/tdigest
repositorypackage
0.1.0
Repository: https://github.com/zeebo/tdigest.git
Documentation: pkg.go.dev

# README

T-Digest

A fast map-reduce and parallel streaming friendly data-structure for accurate quantile approximation.

This package provides an implementation of Ted Dunning's t-digest data structure in Go.

GoDoc

Forked from the excellent caio/go-tdigest to clean up the API and optimize.

Example Usage

package main

import (
	"fmt"
	"math/rand"

	"github.com/zeebo/tdigest"
)

func main() {
	t := tdigest.New(100)

	for i := 0; i < 10000; i++ {
		// Analogue to t.AddWeighted(rand.Float64(), 1)
		t.Add(rand.Float64())
	}

	fmt.Printf("p(.5) = %.6f\n", t.Quantile(0.5))
	fmt.Printf("CDF(Quantile(.5)) = %.6f\n", t.CDF(t.Quantile(0.5)))
}