code: def estimate_mean(Y, sd):
      """Estimate the mean of a sample given information about
      the standard deviations of each entry.
  
      Parameters
      ----------
      Y : ndarray
         Data for which mean is to be estimated.  Should have shape[0] ==
         number of subjects.
      sd : ndarray
         Standard deviation (subject specific) of the data for which the
         mean is to be estimated.  Should have shape[0] == number of
         subjects.
  
      Returns
      -------
      value : dict
         This dictionary has keys ['effect', 'scale', 't', 'resid', 'sd']
      """
      nsubject = Y.shape[0]
      squeeze = False
      if Y.ndim == 1:
          Y = Y.reshape(Y.shape[0], 1)
          squeeze = True
  
      _stretch = lambda x: np.multiply.outer(np.ones(nsubject), x)
  
      W = pos_recipr(sd**2)
      if W.shape in [(), (1,)]:
          W = np.ones(Y.shape) * W
      W.shape = Y.shape
  
      # Compute the mean using the optimal weights
      effect = (Y * W).sum(0) / W.sum(0)
      resid = (Y - _stretch(effect)) * np.sqrt(W)
  
      scale = np.add.reduce(np.power(resid, 2), 0) / (nsubject - 1)
      var_total = scale * pos_recipr(W.sum(0))
  
      value = {}
      value["resid"] = resid
      value["effect"] = effect
      value["sd"] = np.sqrt(var_total)
      value["t"] = value["effect"] * pos_recipr(value["sd"])
      value["scale"] = np.sqrt(scale)
  
      if squeeze:
          for key, val in value.items():
              value[key] = np.squeeze(val)
      return value
  
imports: import numpy
  from ..utils.matrices import pos_recipr
label_desc: Use image node_id 1 for calling a global function with example usage: estimate_mean(Y, sd) and returns: value