Giter VIP home page Giter VIP logo

flyingmutant / bdigest Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 1.0 32 KB

B-digest is a Go library for fast and memory-efficient estimation of quantiles with guaranteed relative error and full mergeability

Home Page: https://pkg.go.dev/pgregory.net/bdigest

License: Apache License 2.0

Go 100.00%
percentile quantile quantile-estimation online-algorithms accuracy accuracy-guarantees aggregation golang

bdigest's Introduction

b-digest PkgGoDev CI

B-digest is a Go library for fast and memory-efficient estimation of quantiles with guaranteed relative error and full mergeability.

package bdigest_test

import (
	"fmt"
	"math"
	"math/rand"

	"pgregory.net/bdigest"
)

func ExampleNewDigest() {
	r := rand.New(rand.NewSource(0))
	d := bdigest.NewDigest(0.05)

	for i := 0; i < 100000; i++ {
		v := math.Exp(r.NormFloat64())
		d.Add(v)
	}

	fmt.Printf("%v buckets\n", d.Size())
	for _, q := range []float64{0, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95, 0.99, 0.999, 0.9999, 1} {
		fmt.Printf("%v\tq%v\n", d.Quantile(q), q)
	}

	// Output:
	// 98 buckets
	// 0.015690260723105844	q0
	// 0.2858480802952493	q0.1
	// 0.5211100423907477	q0.25
	// 1.05	q0.5
	// 1.9141830301785612	q0.75
	// 3.489615879070075	q0.9
	// 5.2076333497857386	q0.95
	// 10.493014090054524	q0.99
	// 21.142683691165157	q0.999
	// 42.601017193748824	q0.9999
	// 258.10858921508054	q1
}

License

B-digest is licensed under the Apache License Version 2.0.

bdigest's People

Contributors

flyingmutant avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

hrissan

bdigest's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.