kll

package
v0.0.0-...-df9bf87 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package kll implements a KLL-style sketch. It give approximate quantile estimates from a stream of values. See: Optimal Quantile Approximation in Streams https://arxiv.org/pdf/1603.05346

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sketch

type Sketch[T cmp.Ordered] struct {
	// contains filtered or unexported fields
}

Sketch accumulates a stream of values

func New

func New[T cmp.Ordered]() *Sketch[T]

New creates a new Sketch with the default k value.

func (*Sketch[T]) Count

func (sk *Sketch[T]) Count() int

Count returns the number of values inserted into the sketch.

func (*Sketch[T]) Insert

func (sk *Sketch[T]) Insert(value T)

Insert adds a new value to the sketch, compacting levels as necessary.

func (*Sketch[T]) Query

func (sk *Sketch[T]) Query(q float64) T

Query returns the approximate value at the given quantile (0.0 <= q <= 1.0). For example, Query(0.5) returns the approximate median.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL