code: func (s Sample) Mean() float64 {
  	if len(s.Xs) == 0 || s.Weights == nil {
  		return Mean(s.Xs)
  	}
  
  	m, wsum := 0.0, 0.0
  	for i, x := range s.Xs {
  		// Use weighted incremental mean:
  		//   m_i = (1 - w_i/wsum_i) * m_(i-1) + (w_i/wsum_i) * x_i
  		//       = m_(i-1) + (x_i - m_(i-1)) * (w_i/wsum_i)
  		w := s.Weights[i]
  		wsum += w
  		m += (x - m) * w / wsum
  	}
  	return m
  }
docs: // Mean returns the arithmetic mean of the Sample.