Skip to content

Commit

Permalink
Document the panic() conditions for TrimmedMean()
Browse files Browse the repository at this point in the history
  • Loading branch information
caio committed Oct 23, 2018
1 parent f5ed1b1 commit ee9572a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tdigest.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,11 @@ func (t TDigest) chooseMergeCandidate(begin, end int, value float64, count uint3
return closest
}

// TrimmedMean returns the mean of the distribution between the two percentiles
// p1 and p2.
// TrimmedMean returns the mean of the distribution between the two
// percentiles p1 and p2.
//
// Values of p1 and p2 must be beetween 0 and 1 (inclusive) and p1
// must be less than p2. Will panic otherwise.
func (t *TDigest) TrimmedMean(p1, p2 float64) float64 {
if p1 < 0 || p1 > 1 {
panic("p1 must be between 0 and 1 (inclusive)")
Expand Down

0 comments on commit ee9572a

Please sign in to comment.