class_docstr: Univariate density estimation by orthonormal series expansion
  
  
  Uses an orthonormal polynomial basis to approximate a univariate density.
  
  
  currently all arguments can be given to fit, I might change it to requiring
  arguments in __init__ instead.
class_docstr_tok: ["Univariate","density","estimation","by","orthonormal","series","expansion","Uses","an","orthonormal","polynomial","basis","to","approximate","a","univariate","density",".","currently","all","arguments","can","be","given","to","fit",",","I","might","change","it","to","requiring","arguments","in","__init__","instead","."]
docstr: estimate the orthogonal polynomial approximation to the density
  
          
docstr_tok: ["estimate","the","orthogonal","polynomial","approximation","to","the","density"]
code: def fit(self, x, polybase=None, order=5, limits=None):
      """estimate the orthogonal polynomial approximation to the density"""
      if polybase is None:
          polys = self.polys[:order]
      else:
          self.polybase = polybase
          self.polys = polys = [polybase(i) for i in range(order)]
  
      # move to init ?
      if not hasattr(self, "offsetfac"):
          self.offsetfac = polys[0].offsetfactor
  
      xmin, xmax = x.min(), x.max()
      if limits is None:
          self.offset = offset = (xmax - xmin) * self.offsetfac
          limits = self.limits = (xmin - offset, xmax + offset)
  
      interval_length = limits[1] - limits[0]
      xinterval = xmax - xmin
      # need to cover (half-)open intervalls
      self.shrink = 1.0 / interval_length  # xinterval/interval_length
      offset = (interval_length - xinterval) / 2.0
      self.shift = xmin - offset
  
      self.x = x = self._transform(x)
  
      coeffs = [(p(x)).mean() for p in polys]
      self.coeffs = coeffs
      self.polys = polys
      self._verify()  # verify that it is a proper density
  
      return self
  
imports: from scipy import stats, integrate, special
  import numpy
label_desc: Use image node_id 2 for calling the DensityOrthoPoly obj's underlying member method code with example usage: obj.fit(x, polybase, order, limits) and returns: self