class_docstr: Empirical distribution (sktime native).
  
  Parameters
  ----------
  spl : pd.DataFrame with pd.MultiIndex
      empirical sample
      last (highest) index is instance, first (lowest) index is sample
  weights : pd.Series, with same index and length as spl, optional, default=None
      if not passed, ``spl`` is assumed to be unweighted
  time_indep : bool, optional, default=True
      if True, ``sample`` will sample individual instance indices independently
      if False, ``sample`` will sample entire instances from ``spl``
  index : pd.Index, optional, default = RangeIndex
  columns : pd.Index, optional, default = RangeIndex
  
  Example
  -------
  >>> import pandas as pd
  >>> from sktime.proba.empirical import Empirical
  
  >>> spl_idx = pd.MultiIndex.from_product(
  ...     [[0, 1], [0, 1, 2]], names=["sample", "time"]
  ... )
  >>> spl = pd.DataFrame(
  ...     [[0, 1], [2, 3], [10, 11], [6, 7], [8, 9], [4, 5]],
  ...     index=spl_idx,
  ...     columns=["a", "b"],
  ... )
  >>> dist = Empirical(spl)
  >>> empirical_sample = dist.sample(3)
class_docstr_tok: ["Empirical","distribution","(","sktime","native",")",".","Parameters","--","--","--","--","--","spl",":","pd.DataFrame","with","pd.MultiIndex","empirical","sample","last","(","highest",")","index","is","instance",",","first","(","lowest",")","index","is","sample","weights",":","pd.Series",",","with","same","index","and","length","as","spl",",","optional",",","default=None","if","not","passed",",","``","spl","``","is","assumed","to","be","unweighted","time_indep",":","bool",",","optional",",","default=True","if","True",",","``","sample","``","will","sample","individual","instance","indices","independently","if","False",",","``","sample","``","will","sample","entire","instances","from","``","spl","``","index",":","pd.Index",",","optional",",","default","=","RangeIndex","columns",":","pd.Index",",","optional",",","default","=","RangeIndex","Example","--","--","--","-",">",">",">","import","pandas","as","pd",">",">",">","from","sktime.proba.empirical","import","Empirical",">",">",">","spl_idx","=","pd.MultiIndex.from_product","(","...","[","[","0",",","1","]",",","[","0",",","1",",","2","]","]",",","names=","[","``","sample","''",",","``","time","''","]","...",")",">",">",">","spl","=","pd.DataFrame","(","...","[","[","0",",","1","]",",","[","2",",","3","]",",","[","10",",","11","]",",","[","6",",","7","]",",","[","8",",","9","]",",","[","4",",","5","]","]",",","...","index=spl_idx",",","...","columns=","[","``","a","''",",","``","b","''","]",",","...",")",">",">",">","dist","=","Empirical","(","spl",")",">",">",">","empirical_sample","=","dist.sample","(","3",")"]
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|]` (per row), "self-energy".
  If `x` is passed, returns :math:`\mathbb{E}[|X-x|]` (per row), "energy wrt x".
  
  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|","]","`","(","per","row",")",",","``","self-energy","''",".","If","`","x","`","is","passed",",","returns",":","math",":","`","\\mathbb","{","E","}","[","|X-x|","]","`","(","per","row",")",",","``","energy","wrt","x","''",".","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|]` (per row), "self-energy".
      If `x` is passed, returns :math:`\mathbb{E}[|X-x|]` (per row), "energy wrt x".
  
      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.
      """
      energy = self._apply_per_ix(
          _energy_np, {"assume_sorted": True}, x=x
      )
      res = pd.DataFrame(energy.sum(axis=1), columns=["energy"])
      return res
  
file_path: sktime/sktime/proba/empirical.py
imports: import numpy
  import pandas
  from sktime.proba.base import BaseDistribution
label_desc: Use image node_id 5 for calling the Empirical obj's underlying member method code with example usage: obj.energy(x) and returns: res