class_docstr: Base probability distribution.
docstr: Energy of self, w.r.t. self or a constant frame x.
  
  Let :math:`X, Y` be i.i.d. random variables with the distribution of `self`.
  
  If `x` is `None`, returns :math:`\mathbb{E}[|X-Y|]` (for each row),
  "self-energy" (of the row marginal distribution).
  If `x` is passed, returns :math:`\mathbb{E}[|X-x|]` (for each row),
  "energy wrt x" (of the row marginal distribution).
  
  Parameters
  ----------
  x : None or pd.DataFrame, optional, default=None
      if pd.DataFrame, must have same rows and columns as `self`
  
  Returns
  -------
  pd.DataFrame with same rows as `self`, single column `"energy"`
  each row contains one float, self-energy/energy as described above.
docstr_tok: ["Energy","of","self",",","w.r.t",".","self","or","a","constant","frame","x",".","Let",":","math",":","`","X",",","Y","`","be","i.i.d",".","random","variables","with","the","distribution","of","`","self","`",".","If","`","x","`","is","`","None","`",",","returns",":","math",":","`","\\mathbb","{","E","}","[","|X-Y|","]","`","(","for","each","row",")",",","''","self-energy","''","(","of","the","row","marginal","distribution",")",".","If","`","x","`","is","passed",",","returns",":","math",":","`","\\mathbb","{","E","}","[","|X-x|","]","`","(","for","each","row",")",",","''","energy","wrt","x","''","(","of","the","row","marginal","distribution",")",".","Parameters","--","--","--","--","--","x",":","None","or","pd.DataFrame",",","optional",",","default=None","if","pd.DataFrame",",","must","have","same","rows","and","columns","as","`","self","`","Returns","--","--","--","-","pd.DataFrame","with","same","rows","as","`","self","`",",","single","column","`","``","energy","''","`","each","row","contains","one","float",",","self-energy\/energy","as","described","above","."]
code: def energy(self, x=None):
      r"""Energy of self, w.r.t. self or a constant frame x.
  
      Let :math:`X, Y` be i.i.d. random variables with the distribution of `self`.
  
      If `x` is `None`, returns :math:`\mathbb{E}[|X-Y|]` (for each row),
      "self-energy" (of the row marginal distribution).
      If `x` is passed, returns :math:`\mathbb{E}[|X-x|]` (for each row),
      "energy wrt x" (of the row marginal distribution).
  
      Parameters
      ----------
      x : None or pd.DataFrame, optional, default=None
          if pd.DataFrame, must have same rows and columns as `self`
  
      Returns
      -------
      pd.DataFrame with same rows as `self`, single column `"energy"`
      each row contains one float, self-energy/energy as described above.
      """
      # we want to approximate E[abs(X-Y)]
      # if x = None, X,Y are i.i.d. copies of self
      # if x is not None, X=x (constant), Y=self
  
      approx_spl_size = self.get_tag("approx_energy_spl")
      approx_method = (
          "by approximating the energy expectation by the arithmetic mean of "
          f"{approx_spl_size} samples"
      )
      warn(self._method_error_msg("energy", fill_in=approx_method))
  
      # splx, sply = i.i.d. samples of X - Y of size N = approx_spl_size
      N = approx_spl_size
      if x is None:
          splx = self.sample(N)
          sply = self.sample(N)
      else:
          splx = pd.concat([x] * N, keys=range(N))
          sply = self.sample(N)
  
      # approx E[abs(X-Y)] via mean of samples of abs(X-Y) obtained from splx, sply
      spl = splx - sply
      energy = spl.apply(np.linalg.norm, axis=1, ord=1)
      energy = energy.groupby(level=1, sort=False).mean()
      energy = pd.DataFrame(
          energy, index=self.index, columns=["energy"]
      )
      return energy
  
imports: from warnings import warn
  import numpy
  import pandas
  from sktime.base import BaseObject
  from sktime.utils.pandas import df_map
  from sktime.utils.validation._dependencies import _check_estimator_deps
label_desc: Use image node_id 16 for calling the BaseDistribution obj's underlying member method code with example usage: obj.energy(x) and returns: energy