Codebase list golang-github-beorn7-perks / 166701f
Formatting and typo fixes Caleb Spare authored 9 years ago Blake Mizerany committed 9 years ago
2 changed file(s) with 6 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
00 // Package histogram provides a Go implementation of BigML's histogram package
1 // for Clojure/Java. It is currently experiemental.
1 // for Clojure/Java. It is currently experimental.
22 package histogram
33
44 import (
2929 // Samples represents a slice of samples. It implements sort.Interface.
3030 type Samples []Sample
3131
32 func (a Samples) Len() int {
33 return len(a)
34 }
35
36 func (a Samples) Less(i, j int) bool {
37 return a[i].Value < a[j].Value
38 }
39
40 func (a Samples) Swap(i, j int) {
41 a[i], a[j] = a[j], a[i]
42 }
32 func (a Samples) Len() int { return len(a) }
33 func (a Samples) Less(i, j int) bool { return a[i].Value < a[j].Value }
34 func (a Samples) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
4335
4436 type invariant func(s *stream, r float64) float64
4537
4638 // NewBiased returns an initialized Stream for high-biased quantiles (e.g.
47 // 50th, 90th, 99th) not known a priori with finer error guarantees for the
39 // 50th, 90th, 99th) not known a priori with finer error guarantees for the
4840 // higher ranks of the data distribution.
4941 // See http://www.cs.rutgers.edu/~muthu/bquant.pdf for time, space, and error properties.
5042 func NewBiased() *Stream {
111103 func (s *Stream) Query(q float64) float64 {
112104 if !s.flushed() {
113105 // Fast path when there hasn't been enough data for a flush;
114 // this also yeilds better accuracy for small sets of data.
106 // this also yields better accuracy for small sets of data.
115107 l := len(s.b)
116108 if l == 0 {
117109 return 0