code: def calculate_mean(samples, weights):
      r'''Calculate the mean of weighted samples (like the output of an
      importance-sampling run).
  
      :param samples:
  
          Matrix-like numpy array; the samples to be used.
  
      :param weights:
  
          Vector-like numpy array; the (unnormalized) importance weights.
  
      '''
      assert len(samples) == len(weights), "The number of samples (got %i) must equal the number of weights (got %i)." % (len(samples),len(weights))
      return _np.average(samples, axis=0, weights=weightsf calculate_mean(samples, weights):
      r'''Calculate the mean of weighted samples (like the output of an
      importance-sampling run).
  
      :param samples:
  
          Matrix-like numpy array; the samples to be used.
  
      :param weights:
  
          Vector-like numpy array; the (unnormalized) importance weights.
  
      '''
      assert len(samples) == len(weights), "The number of samples (got %i) must equal the number of weights (got %i)." % (len(samples),len(weights))
      return _np.average(samples, axis=0, weights=weights)
docs: r'''Calculate the mean of weighted samples (like the output of an
      importance-sampling run).
  
      :param samples:
  
          Matrix-like numpy array; the samples to be used.
  
      :param weights:
  
          Vector-like numpy array; the (unnormalized) importance weights.