Giter VIP home page Giter VIP logo

fuzzyquantile's Introduction

FuzzyQuantile

GoDoc Go Report Card

High performance quantile estimation(e.g. 90th, 95th, 99th) over unbounded streaming data, within expected error (e.g 0.1%) and low memory usage.

This is an implementation of the algorithm presented in Cormode, Korn, Muthukrishnan, and Srivastava. "Effective Computation of Biased Quantiles over Data Streams" in ICDE 2005.

Install

go get github.com/simon-xia/fuzzyQuantile

Benchmark

On my laptop (MacBook Pro 15-inch Mid 2015, 2.2 GHz Intel Core i7), run the test case TestFuzzyQuantileTarget. Inserted 10 M values takes 4.04s, only 3143 values were stored, which means 99.96857% value were dropped. And quantile query error were all as expected.

benchmark

Usage

This example show target quantile estimation. Given a set of Quantiles, each Quantile instance repsent a pair (quantile, error) which means expected quantile value with the error. And query will give the result quantile value corresponding error.

testQuantiles := []Quantile{
	NewQuantile(0.5, 0.01),
	NewQuantile(0.8, 0.001),
	NewQuantile(0.95, 0.0001),
}

fq := NewFuzzyQuantile(&FuzzyQuantileConf{Quantiles: testQuantiles})

// valueChan repsent a data stream source
valueChan := make(chan float64)
for v := range valueChan {
	fq.Insert(v)
   }
   
// valueChan close at other place

v, er := fq.Query(0.8)
if er != nil {
	// handle error
}
log.Printf("success 80th percentile value %v", v)

For other usage, check the document or testcase in source code.

More details(Chinese): 无穷数据流的分位数问题

TODO

  • RBTree Storage Impl
  • More graceful log

fuzzyquantile's People

Contributors

simon-xia avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

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.