Documentation
¶
Overview ¶
Package histogram is a helper to quickly create histograms from slices of float64.
You can use it with any numeric value, given that you convert it back and forth to []float64.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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. If // this bucket is the last bucket, the bound is inclusive // and contains the max value of the histogram. Max float64 }
Bucket counts a partion of values.
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.
func HistByCustomRange ¶
HistByCustomRange creates an histogram by custom range, like elasticsearch data histogram query(left closed)
Click to show internal directories.
Click to hide internal directories.