Documentation
¶
Index ¶
- func BSArbitrarySpan(start float64, stop float64, nbins int) func([]float64) ([]Bucket, error)
- func BSExactSpan(nb int) func([]float64) ([]Bucket, error)
- func DefaultBucketer(val float64, bs []Bucket) int
- func Fprint(w io.Writer, h *Histogram, s ScaleFunc) error
- func Fprintf(w io.Writer, h *Histogram, s ScaleFunc, f FormatFunc) error
- type Bucket
- type Bucketer
- type FormatFunc
- type Histogram
- type ScaleFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BSArbitrarySpan ¶
BSArbitrarySpan returns Buckets conforming to start, stop, and nbins.
func BSExactSpan ¶
BSExactSpan returns Buckets that span the input array from the smallest input to the largest input exactly.
func DefaultBucketer ¶
DefaultBucketer uses BinearySearchFunc to bucket the supplied value.
func Fprint ¶
Fprint prints a unicode histogram on the io.Writer, using scale s. This code:
hist := Hist(9, data) err := Fprint(os.Stdout, hist, Linear(5))
... yields the graph:
0.1-0.2 5% ▋1 0.2-0.3 25% ██▋5 0.3-0.4 0% ▏ 0.4-0.5 5% ▋1 0.5-0.6 50% █████▏10 0.6-0.7 0% ▏ 0.7-0.8 0% ▏ 0.8-0.9 5% ▋1 0.9-1 10% █▏2
Types ¶
type Bucket ¶
type Bucket struct {
// Count is the number of values represented in the bucket.
Count int
// Min is the low, inclusive bound of the bucket.
Min float64
// Max is the high, exclusive bound of the bucket.
Max float64
}
Bucket counts a partion of values.
type Bucketer ¶
Bucketer is a function that takes a value and returns the bucket index in the supplied slice of Buckets. Implementations should return -1 if the value does not fit in a bucket. Callers MUST ensure that bs is sorted.
type FormatFunc ¶
FormatFunc formats a float into the proper string form. Used to print meaningful axe labels.
type Histogram ¶
type Histogram 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
}
Histogram holds a count of values partionned over buckets.