histogram

package
v0.0.0-...-0e64b7e Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: MIT Imports: 4 Imported by: 0

README

histogram

Go Reference

Influenced by github.com/aybabtme/uniplot/histogram

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket[T Indexable] struct {

	// Min is the low, inclusive bound of the bucket.
	Min T
	// Max is the high, exclusive bound of the bucket. If
	// this bucket is the last bucket, the bound is inclusive
	// and contains the max value of the histogram.
	Max T
	// Count is the number of values represented in the bucket.
	Count int
	// contains filtered or unexported fields
}

Bucket counts a partion of values.

type Histogram

type Histogram[T Indexable] struct {
	// Min is the size of the smallest bucket.
	Min int
	// Max is the size of the biggest bucket.
	Max int
	// Count is the total size of all buckets.
	Count int
	// Buckets over which values are partionned.
	Buckets []Bucket[T]
}

Histogram holds a count of values partioned over buckets.

func Create

func Create[T Indexable](bins int, input []T) Histogram[T]

Create creates an histogram partioning input over `bins` buckets

func CreateLog

func CreateLog[T Indexable](power float64, input []T) Histogram[T]

CreateLog creates an histogram with logarithmic partioning

func CreateRanged

func CreateRanged[T Indexable](minValue, maxValue, interval T, input []T) Histogram[T]

CreateRanged creates a histogram by custom range

func (Histogram[T]) Index

func (h Histogram[T]) Index(val T) (int, error)

Index finds the index of the Bucket set that a value falls into

type Indexable

type Indexable interface {
	constraints.Unsigned | constraints.Signed | constraints.Float
}

Indexable defines the constraints for Histogram values

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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