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: Sample from the distribution.
  
  Parameters
  ----------
  n_samples : int, optional, default = None
  
  Returns
  -------
  if `n_samples` is `None`:
  returns a sample that contains a single sample from `self`,
  in `pd.DataFrame` mtype format convention, with `index` and `columns` as `self`
  if n_samples is `int`:
  returns a `pd.DataFrame` that contains `n_samples` i.i.d. samples from `self`,
  in `pd-multiindex` mtype format convention, with same `columns` as `self`,
  and `MultiIndex` that is product of `RangeIndex(n_samples)` and `self.index`
docstr_tok: ["Sample","from","the","distribution",".","Parameters","--","--","--","--","--","n_samples",":","int",",","optional",",","default","=","None","Returns","--","--","--","-","if","`","n_samples","`","is","`","None","`",":","returns","a","sample","that","contains","a","single","sample","from","`","self","`",",","in","`","pd.DataFrame","`","mtype","format","convention",",","with","`","index","`","and","`","columns","`","as","`","self","`","if","n_samples","is","`","int","`",":","returns","a","`","pd.DataFrame","`","that","contains","`","n_samples","`","i.i.d",".","samples","from","`","self","`",",","in","`","pd-multiindex","`","mtype","format","convention",",","with","same","`","columns","`","as","`","self","`",",","and","`","MultiIndex","`","that","is","product","of","`","RangeIndex","(","n_samples",")","`","and","`","self.index","`"]
code: def sample(self, n_samples=None):
      """Sample from the distribution.
  
      Parameters
      ----------
      n_samples : int, optional, default = None
  
      Returns
      -------
      if `n_samples` is `None`:
      returns a sample that contains a single sample from `self`,
      in `pd.DataFrame` mtype format convention, with `index` and `columns` as `self`
      if n_samples is `int`:
      returns a `pd.DataFrame` that contains `n_samples` i.i.d. samples from `self`,
      in `pd-multiindex` mtype format convention, with same `columns` as `self`,
      and `MultiIndex` that is product of `RangeIndex(n_samples)` and `self.index`
      """
      spl = self.spl
      timestamps = self._timestamps
      weights = self.weights
  
      if n_samples is None:
          n_samples = 1
          n_samples_was_none = True
      else:
          n_samples_was_none = False
      smpls = []
  
      for _ in range(n_samples):
          smpls_i = []
          for t in timestamps:
              spl_from = spl.loc[(slice(None), t), :]
              if weights is not None:
                  spl_weights = weights.loc[(slice(None), t)].values
              else:
                  spl_weights = None
              spl_time = spl_from.sample(
                  n=1, replace=True, weights=spl_weights
              )
              spl_time = spl_time.droplevel(0)
              smpls_i.append(spl_time)
          spl_i = pd.concat(smpls_i, axis=0)
          smpls.append(spl_i)
  
      spl = pd.concat(smpls, axis=0, keys=range(n_samples))
      if n_samples_was_none:
          spl = spl.droplevel(0)
  
      return spl
  
file_path: sktime/sktime/proba/empirical.py
imports: import numpy
  import pandas
  from sktime.proba.base import BaseDistribution
label_desc: Use image node_id 10 for calling the Empirical obj's underlying member method code with example usage: obj.sample(n_samples) and returns: spl