// note: expect sorted list
expect sorted list
// note : expect sorted list
func (m *HistogramMetrics) percentile(n float64) Data {
	m.value.mu.RLock()
	defer m.value.mu.RUnlock()
	list := m.value.v
	if 1.0 <= n || len(list) < minPercentileSize {
		return &Float{}
	}
	r := 1 + float64((len(list)-1))*n
	rFloor := int(math.Floor(r))
	rCeil := int(math.Ceil(r))
	q := list[rFloor-1] + (r-float64(rFloor))*(list[rCeil-1]-list[rFloor-1])
	return &Float{
		f: q,
	}
}
func ( m * HistogramMetrics ) percentile ( n float64 ) Data { m . value . mu . RLock ( ) defer m . value . mu . RUnlock ( ) list := m . value . v if 1.0 <= n || len ( list ) < minPercentileSize { return & Float { } } r := 1 + float64 ( ( len ( list ) - 1 ) ) * n rFloor := int ( math . Floor ( r ) ) rCeil := int ( math . Ceil ( r ) ) q := list [ rFloor - 1 ] + ( r - float64 ( rFloor ) ) * ( list [ rCeil - 1 ] - list [ rFloor - 1 ] ) return & Float { f : q , } }
expect sorted list
expect sorted list
// use linear interpolation // see type R-7: https://en.wikipedia.org/wiki/Quantile // -1 means in accordance with slice index