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: Return element/entry-wise variance of the distribution.
  
  Let :math:`X` be a random variable with the distribution of `self`.
  Returns :math:`\mathbb{V}[X] = \mathbb{E}\left(X - \mathbb{E}[X]\right)^2`
  
  Returns
  -------
  pd.DataFrame with same rows, columns as `self`
  variance of distribution (entry-wise)
docstr_tok: ["Return","element\/entry-wise","variance","of","the","distribution",".","Let",":","math",":","`","X","`","be","a","random","variable","with","the","distribution","of","`","self","`",".","Returns",":","math",":","`","\\mathbb","{","V","}","[","X","]","=","\\mathbb","{","E","}","\\left","(","X","-","\\mathbb","{","E","}","[","X","]","\\right",")","^2","`","Returns","--","--","--","-","pd.DataFrame","with","same","rows",",","columns","as","`","self","`","variance","of","distribution","(","entry-wise",")"]
code: def var(self):
      r"""Return element/entry-wise variance of the distribution.
  
      Let :math:`X` be a random variable with the distribution of `self`.
      Returns :math:`\mathbb{V}[X] = \mathbb{E}\left(X - \mathbb{E}[X]\right)^2`
  
      Returns
      -------
      pd.DataFrame with same rows, columns as `self`
      variance of distribution (entry-wise)
      """
      spl = self.spl
      N = self._N
      if self.weights is None:
          var_df = spl.groupby(level=-1, sort=False).var(ddof=0)
      else:
          mean = self.mean()
          means = pd.concat(
              [mean] * N, axis=0, keys=self._spl_instances
          )
          var_df = spl.groupby(level=-1, sort=False).apply(
              lambda x: np.average(
                  (x - means.loc[x.index]) ** 2,
                  weights=self.weights.loc[x.index],
                  axis=0,
              )
          )
          var_df = pd.DataFrame(
              var_df.tolist(), index=var_df.index, columns=spl.columns
          )
      return var_df
  
file_path: sktime/sktime/proba/empirical.py
imports: import numpy
  import pandas
  from sktime.proba.base import BaseDistribution
label_desc: Use image node_id 7 for calling the Empirical obj's underlying member method code with example usage: obj.var() and returns: var_df