romspline/greedy.py
def greedy(self, x, y, tol=1e-6, rel=False, deg=5, verbose=False, seeds=None):
    """
    Greedy algorithm for finding optimal knots to build a reduced-order 
    spline interpolant
    
    Input
    -----
    x       -- samples
    y       -- data to be downsampled
    deg     -- degree of interpolating polynomials 
               (default 5)
    tol     -- L-infinity error tolerance for reduced-order spline 
               (default 1e-6)
    rel     -- L-infinity error tolerance is relative to max abs of data?
               (default is False)
    verbose -- write greedy algorithm output to screen 
               (default False)
    seeds   -- seed indexes for greedy algorithm 
               (default is None (equally spaced))
    
    Output attributes
    -----------------
    errors      -- L-infinity errors of successive spline interpolants 
                   produced by greedy algorithm until tol is reached
    X           -- Nearly optimal data samples for spline interpolant of given order
    Y           -- Nearly optimal data values for spline interpolant of given order
    indices     -- Sorted array indices of greedy-selected data
    args        -- Unsorted array indices of greedy-selected data
    size        -- Number of points retained for reduced-order spline
    compression -- Ratio of original data length to size
    
    Comments
    --------
    If x is not given then interpolation is built using y array index labels
    as the samples.
    """
    
    self._deg = deg
    self._rel = rel
    
    if rel:
      ymax = np.max(np.abs(y))
      assert ymax > 0., "All data samples are zero."
    else:
      ymax = 1.
    self._tol = tol
    #self.tol = self._tol*ymax
    
    # Seed greedy algorithm
    if seeds is None:
      self._seed = _seed(x, deg=self._deg, seeds=None)[0]
    else:
      self._seed = seeds
      
    # Greedy algorithm
    self._spline, self.indices, self.args, self.errors, self.tol = _greedy(x, y, tol=self._tol, rel=self._rel, deg=self._deg, verbose=verbose, seeds=seeds)
    
    # Define some attributes for spline evaluation
    self.X = x[self.indices]
    self.Y = y[self.indices]
    self.size = len(self.indices)
    self.compression = float(len(y))/self.size
    self._made = True

    Greedy algorithm for finding optimal knots to build a reduced-order 
    spline interpolant
    
    Input
    -----
    x       -- samples
    y       -- data to be downsampled
    deg     -- degree of interpolating polynomials 
               (default 5)
    tol     -- L-infinity error tolerance for reduced-order spline 
               (default 1e-6)
    rel     -- L-infinity error tolerance is relative to max abs of data?
               (default is False)
    verbose -- write greedy algorithm output to screen 
               (default False)
    seeds   -- seed indexes for greedy algorithm 
               (default is None (equally spaced))
    
    Output attributes
    -----------------
    errors      -- L-infinity errors of successive spline interpolants 
                   produced by greedy algorithm until tol is reached
    X           -- Nearly optimal data samples for spline interpolant of given order
    Y           -- Nearly optimal data values for spline interpolant of given order
    indices     -- Sorted array indices of greedy-selected data
    args        -- Unsorted array indices of greedy-selected data
    size        -- Number of points retained for reduced-order spline
    compression -- Ratio of original data length to size
    
    Comments
    --------
    If x is not given then interpolation is built using y array index labels
    as the samples.
    
Greedy algorithm for finding optimal knots to build a reduced-order
spline interpolant

Input



Output attributes



Comments

If x is not given then interpolation is built using y array index labels
as the samples.
Greedy algorithm for finding optimal knots to build a reduced - order spline interpolant Input Output attributes Comments If x is not given then interpolation is built using y array index labels as the samples .
def greedy(self, x, y, tol=1e-6, rel=False, deg=5, verbose=False, seeds=None):
    self._deg = deg
    self._rel = rel
    if rel:
      ymax = np.max(np.abs(y))
      assert ymax > 0., "All data samples are zero."
    else:
      ymax = 1.
    self._tol = tol
    if seeds is None:
      self._seed = _seed(x, deg=self._deg, seeds=None)[0]
    else:
      self._seed = seeds
    self._spline, self.indices, self.args, self.errors, self.tol = _greedy(x, y, tol=self._tol, rel=self._rel, deg=self._deg, verbose=verbose, seeds=seeds)
    self.X = x[self.indices]
    self.Y = y[self.indices]
    self.size = len(self.indices)
    self.compression = float(len(y))/self.size
    self._made = True
def greedy ( self , x , y , tol = 1e-6 , rel = False , deg = 5 , verbose = False , seeds = None ) : self . _deg = deg self . _rel = rel if rel : ymax = np . max ( np . abs ( y ) ) assert ymax > 0. , "All data samples are zero." else : ymax = 1. self . _tol = tol if seeds is None : self . _seed = _seed ( x , deg = self . _deg , seeds = None ) [ 0 ] else : self . _seed = seeds self . _spline , self . indices , self . args , self . errors , self . tol = _greedy ( x , y , tol = self . _tol , rel = self . _rel , deg = self . _deg , verbose = verbose , seeds = seeds ) self . X = x [ self . indices ] self . Y = y [ self . indices ] self . size = len ( self . indices ) self . compression = float ( len ( y ) ) / self . size self . _made = True
Greedy algorithm for finding optimal knots to build a reduced-order
spline interpolant
Greedy algorithm for finding optimal knots to build a reduced - order spline interpolant
"""
    Greedy algorithm for finding optimal knots to build a reduced-order 
    spline interpolant
    
    Input
    -----
    x       -- samples
    y       -- data to be downsampled
    deg     -- degree of interpolating polynomials 
               (default 5)
    tol     -- L-infinity error tolerance for reduced-order spline 
               (default 1e-6)
    rel     -- L-infinity error tolerance is relative to max abs of data?
               (default is False)
    verbose -- write greedy algorithm output to screen 
               (default False)
    seeds   -- seed indexes for greedy algorithm 
               (default is None (equally spaced))
    
    Output attributes
    -----------------
    errors      -- L-infinity errors of successive spline interpolants 
                   produced by greedy algorithm until tol is reached
    X           -- Nearly optimal data samples for spline interpolant of given order
    Y           -- Nearly optimal data values for spline interpolant of given order
    indices     -- Sorted array indices of greedy-selected data
    args        -- Unsorted array indices of greedy-selected data
    size        -- Number of points retained for reduced-order spline
    compression -- Ratio of original data length to size
    
    Comments
    --------
    If x is not given then interpolation is built using y array index labels
    as the samples.
    """ #self.tol = self._tol*ymax # Seed greedy algorithm # Greedy algorithm # Define some attributes for spline evaluation
self
x
y
tol
rel
deg
verbose
seeds