Skip to content

GoWebProd/psqr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

psqr

Go implementation of The P-Square Algorithm for Dynamic Calculation of Quantiles and Histograms Without Storing Observations.

The algorithm is proposed for dynamic calculation of [..] quantiles. The estimates are produced dynamically as the observations are generated. The observations are not stored, therefore, the algorithm has a very small and fixed storage requirement regardless of the number of observations.

Usage example

package main

import (
	"fmt"
	
	"github.com/GoWebProd/psqr"
)

func main() {
	pp := psqr.NewPSQuantile(0.5, 0.9, 0.99, 0.999)

	pp.Append(0.013163238)
	pp.Append(0.711542201)
	pp.Append(-2.131796046)
	pp.Append(0.244640008)
	pp.Append(-0.211374733)
	pp.Append(4.493872061)

	fmt.Println("0.5 =", pp.Quantile(0.5))
	fmt.Println("0.9 =", pp.Quantile(0.9))
	fmt.Println("0.99 =", pp.Quantile(0.99))
	fmt.Println("0.999 =", pp.Quantile(0.999))
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages