https://github.com/gowebprod/psqr
https://github.com/gowebprod/psqr
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/gowebprod/psqr
- Owner: GoWebProd
- Created: 2019-07-09T11:01:03.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-06-05T15:34:58.000Z (about 6 years ago)
- Last Synced: 2025-08-14T15:58:30.057Z (10 months ago)
- Language: Go
- Size: 3.91 KB
- Stars: 4
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
Awesome Lists containing this project
README
# psqr
Go implementation of [The P-Square Algorithm for Dynamic Calculation of Quantiles and Histograms Without Storing Observations][1].
> 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.
[1]: http://www.cs.wustl.edu/~jain/papers/ftp/psqr.pdf
## Usage example
```go
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))
}
```