code: func (h *NumericHistogram) trim() {
  	for len(h.bins) > h.maxbins {
  		// Find closest bins in terms of value
  		minDelta := 1e99
  		minDeltaIndex := 0
  		for i := range h.bins {
  			if i == 0 {
  				continue
  			}
  
  			if delta := h.bins[i].value - h.bins[i-1].value; delta < minDelta {
  				minDelta = delta
  				minDeltaIndex = i
  			}
  		}
  
  		// We need to merge bins minDeltaIndex-1 and minDeltaIndex
  		totalCount := h.bins[minDeltaIndex-1].count + h.bins[minDeltaIndex].count
  		mergedbin := bin{
  			value: (h.bins[minDeltaIndex-1].value*
  				h.bins[minDeltaIndex-1].count +
  				h.bins[minDeltaIndex].value*
  					h.bins[minDeltaIndex].count) /
  				totalCount, // weighted average
  			count: totalCount, // summed heights
  		}
  		head := append(make([]bin, 0), h.bins[0:minDeltaIndex-1]...)
  		tail := append([]bin{mergedbin}, h.bins[minDeltaIndex+1:]...)
  		h.bins = append(head, tail...)
  	}
  }
docs: // trim merges adjacent bins to decrease the bin count to the maximum value