class_docstr: Univariate Kernel Density Estimator.
  
  Parameters
  ----------
  endog : array_like
      The variable for which the density estimate is desired.
  
  Notes
  -----
  If cdf, sf, cumhazard, or entropy are computed, they are computed based on
  the definition of the kernel rather than the FFT approximation, even if
  the density is fit with FFT = True.
  
  `KDEUnivariate` is much faster than `KDEMultivariate`, due to its FFT-based
  implementation.  It should be preferred for univariate, continuous data.
  `KDEMultivariate` also supports mixed data.
  
  See Also
  --------
  KDEMultivariate
  kdensity, kdensityfft
  
  Examples
  --------
  >>> import statsmodels.api as sm
  >>> import matplotlib.pyplot as plt
  
  >>> nobs = 300
  >>> np.random.seed(1234)  # Seed random generator
  >>> dens = sm.nonparametric.KDEUnivariate(np.random.normal(size=nobs))
  >>> dens.fit()
  >>> plt.plot(dens.cdf)
  >>> plt.show()
class_docstr_tok: ["Univariate","Kernel","Density","Estimator",".","Parameters","--","--","--","--","--","endog",":","array_like","The","variable","for","which","the","density","estimate","is","desired",".","Notes","--","--","-","If","cdf",",","sf",",","cumhazard",",","or","entropy","are","computed",",","they","are","computed","based","on","the","definition","of","the","kernel","rather","than","the","FFT","approximation",",","even","if","the","density","is","fit","with","FFT","=","True",".","`","KDEUnivariate","`","is","much","faster","than","`","KDEMultivariate","`",",","due","to","its","FFT-based","implementation",".","It","should","be","preferred","for","univariate",",","continuous","data",".","`","KDEMultivariate","`","also","supports","mixed","data",".","See","Also","--","--","--","--","KDEMultivariate","kdensity",",","kdensityfft","Examples","--","--","--","--",">",">",">","import","statsmodels.api","as","sm",">",">",">","import","matplotlib.pyplot","as","plt",">",">",">","nobs","=","300",">",">",">","np.random.seed","(","1234",")","#","Seed","random","generator",">",">",">","dens","=","sm.nonparametric.KDEUnivariate","(","np.random.normal","(","size=nobs",")",")",">",">",">","dens.fit","(",")",">",">",">","plt.plot","(","dens.cdf",")",">",">",">","plt.show","(",")"]
docstr: Attach the density estimate to the KDEUnivariate class.
  
  Parameters
  ----------
  kernel : str
      The Kernel to be used. Choices are:
  
      - "biw" for biweight
      - "cos" for cosine
      - "epa" for Epanechnikov
      - "gau" for Gaussian.
      - "tri" for triangular
      - "triw" for triweight
      - "uni" for uniform
  
  bw : str, float, callable
      The bandwidth to use. Choices are:
  
      - "scott" - 1.059 * A * nobs ** (-1/5.), where A is
        `min(std(x),IQR/1.34)`
      - "silverman" - .9 * A * nobs ** (-1/5.), where A is
        `min(std(x),IQR/1.34)`
      - "normal_reference" - C * A * nobs ** (-1/5.), where C is
        calculated from the kernel. Equivalent (up to 2 dp) to the
        "scott" bandwidth for gaussian kernels. See bandwidths.py
      - If a float is given, its value is used as the bandwidth.
      - If a callable is given, it's return value is used.
        The callable should take exactly two parameters, i.e.,
        fn(x, kern), and return a float, where:
  
        * x - the clipped input data
        * kern - the kernel instance used
  
  fft : bool
      Whether or not to use FFT. FFT implementation is more
      computationally efficient. However, only the Gaussian kernel
      is implemented. If FFT is False, then a 'nobs' x 'gridsize'
      intermediate array is created.
  gridsize : int
      If gridsize is None, max(len(x), 50) is used.
  cut : float
      Defines the length of the grid past the lowest and highest values
      of x so that the kernel goes to zero. The end points are
      ``min(x) - cut * adjust * bw`` and ``max(x) + cut * adjust * bw``.
  adjust : float
      An adjustment factor for the bw. Bandwidth becomes bw * adjust.
  
  Returns
  -------
  KDEUnivariate
      The instance fit,
docstr_tok: ["Attach","the","density","estimate","to","the","KDEUnivariate","class",".","Parameters","--","--","--","--","--","kernel",":","str","The","Kernel","to","be","used",".","Choices","are",":","-","``","biw","''","for","biweight","-","``","cos","''","for","cosine","-","``","epa","''","for","Epanechnikov","-","``","gau","''","for","Gaussian",".","-","``","tri","''","for","triangular","-","``","triw","''","for","triweight","-","``","uni","''","for","uniform","bw",":","str",",","float",",","callable","The","bandwidth","to","use",".","Choices","are",":","-","``","scott","''","-","1.059","*","A","*","nobs","*","*","(","-1\/5",".",")",",","where","A","is","`","min","(","std","(","x",")",",","IQR\/1.34",")","`","-","``","silverman","''","-",".9","*","A","*","nobs","*","*","(","-1\/5",".",")",",","where","A","is","`","min","(","std","(","x",")",",","IQR\/1.34",")","`","-","``","normal_reference","''","-","C","*","A","*","nobs","*","*","(","-1\/5",".",")",",","where","C","is","calculated","from","the","kernel",".","Equivalent","(","up","to","2","dp",")","to","the","``","scott","''","bandwidth","for","gaussian","kernels",".","See","bandwidths.py","-","If","a","float","is","given",",","its","value","is","used","as","the","bandwidth",".","-","If","a","callable","is","given",",","it","'s","return","value","is","used",".","The","callable","should","take","exactly","two","parameters",",","i.e.",",","fn","(","x",",","kern",")",",","and","return","a","float",",","where",":","*","x","-","the","clipped","input","data","*","kern","-","the","kernel","instance","used","fft",":","bool","Whether","or","not","to","use","FFT",".","FFT","implementation","is","more","computationally","efficient",".","However",",","only","the","Gaussian","kernel","is","implemented",".","If","FFT","is","False",",","then","a","'nobs","'","x","'gridsize'","intermediate","array","is","created",".","gridsize",":","int","If","gridsize","is","None",",","max","(","len","(","x",")",",","50",")","is","used",".","cut",":","float","Defines","the","length","of","the","grid","past","the","lowest","and","highest","values","of","x","so","that","the","kernel","goes","to","zero",".","The","end","points","are","``","min","(","x",")","-","cut","*","adjust","*","bw","``","and","``","max","(","x",")","+","cut","*","adjust","*","bw","``",".","adjust",":","float","An","adjustment","factor","for","the","bw",".","Bandwidth","becomes","bw","*","adjust",".","Returns","--","--","--","-","KDEUnivariate","The","instance","fit",","]
code: def fit(
      self,
      kernel="gau",
      bw="normal_reference",
      fft=True,
      weights=None,
      gridsize=None,
      adjust=1,
      cut=3,
      clip=(-np.inf, np.inf),
  ):
      """
      Attach the density estimate to the KDEUnivariate class.
  
      Parameters
      ----------
      kernel : str
          The Kernel to be used. Choices are:
  
          - "biw" for biweight
          - "cos" for cosine
          - "epa" for Epanechnikov
          - "gau" for Gaussian.
          - "tri" for triangular
          - "triw" for triweight
          - "uni" for uniform
  
      bw : str, float, callable
          The bandwidth to use. Choices are:
  
          - "scott" - 1.059 * A * nobs ** (-1/5.), where A is
            `min(std(x),IQR/1.34)`
          - "silverman" - .9 * A * nobs ** (-1/5.), where A is
            `min(std(x),IQR/1.34)`
          - "normal_reference" - C * A * nobs ** (-1/5.), where C is
            calculated from the kernel. Equivalent (up to 2 dp) to the
            "scott" bandwidth for gaussian kernels. See bandwidths.py
          - If a float is given, its value is used as the bandwidth.
          - If a callable is given, it's return value is used.
            The callable should take exactly two parameters, i.e.,
            fn(x, kern), and return a float, where:
  
            * x - the clipped input data
            * kern - the kernel instance used
  
      fft : bool
          Whether or not to use FFT. FFT implementation is more
          computationally efficient. However, only the Gaussian kernel
          is implemented. If FFT is False, then a 'nobs' x 'gridsize'
          intermediate array is created.
      gridsize : int
          If gridsize is None, max(len(x), 50) is used.
      cut : float
          Defines the length of the grid past the lowest and highest values
          of x so that the kernel goes to zero. The end points are
          ``min(x) - cut * adjust * bw`` and ``max(x) + cut * adjust * bw``.
      adjust : float
          An adjustment factor for the bw. Bandwidth becomes bw * adjust.
  
      Returns
      -------
      KDEUnivariate
          The instance fit,
      """
      if isinstance(bw, str):
          self.bw_method = bw
      else:
          self.bw_method = "user-given"
          if not callable(bw):
              bw = float_like(bw, "bw")
  
      endog = self.endog
  
      if fft:
          if kernel != "gau":
              msg = "Only gaussian kernel is available for fft"
              raise NotImplementedError(msg)
          if weights is not None:
              msg = "Weights are not implemented for fft"
              raise NotImplementedError(msg)
          density, grid, bw = kdensityfft(
              endog,
              kernel=kernel,
              bw=bw,
              adjust=adjust,
              weights=weights,
              gridsize=gridsize,
              clip=clip,
              cut=cut,
          )
      else:
          density, grid, bw = kdensity(
              endog,
              kernel=kernel,
              bw=bw,
              adjust=adjust,
              weights=weights,
              gridsize=gridsize,
              clip=clip,
              cut=cut,
          )
      self.density = density
      self.support = grid
      self.bw = bw
      self.kernel = kernel_switch[kernel](h=bw)  # we instantiate twice,
      # should this passed to funcs?
      # put here to ensure empty cache after re-fit with new options
      self.kernel.weights = weights
      if weights is not None:
          self.kernel.weights /= weights.sum()
      self._cache = {}
      return self
  
file_path: statsmodels/statsmodels/nonparametric/kde.py
imports: import numpy
  from scipy import integrate, stats
  from statsmodels.sandbox.nonparametric import kernels
  from statsmodels.tools.decorators import cache_readonly
  from statsmodels.tools.validation import array_like, float_like
  from .None import bandwidths
  from .kdetools import forrt, revrt, silverman_transform
  from .linbin import fast_linbin
label_desc: Use image node_id 2 for calling the KDEUnivariate obj's underlying member method code with example usage: obj.fit(kernel, bw, fft, weights, gridsize, adjust, cut, clip) and returns: self