@@ -272,44 +272,83 @@ def tighten(self):
272272 """
273273 raise NotImplementedError
274274
275- def filterbank_bounds (self , N = 999 , bounds = None ):
275+ def estimate_frame_bounds (self , min = 0 , max = None , N = 1000 ,
276+ use_eigenvalues = False ):
276277 r"""
277- Compute approximate frame bounds for a filterbank.
278+ Compute approximate frame bounds for the filterbank.
279+
280+ The frame bounds are estimated using the vector :code:`np.linspace(min,
281+ max, N)` with min=0 and max=G.lmax by default. The eigenvalues G.e can
282+ be used instead if you set use_eigenvalues to True.
278283
279284 Parameters
280285 ----------
281- bounds : interval to compute the bound.
282- Given in an ndarray: np.array([xmin, xnmax]).
283- By default, bounds is None and filtering is bounded
284- by the eigenvalues of G.
285- N : Number of point for the line search
286- Default is 999
286+ min : float
287+ The lowest value the filter bank is evaluated at. By default
288+ filtering is bounded by the eigenvalues of G, i.e. min = 0.
289+ max : float
290+ The largest value the filter bank is evaluated at. By default
291+ filtering is bounded by the eigenvalues of G, i.e. max = G.lmax.
292+ N : int
293+ Number of points where the filter bank is evaluated.
294+ Default is 1000.
295+ use_eigenvalues : bool
296+ Set to True to use the Laplacian eigenvalues instead.
287297
288298 Returns
289299 -------
290- lower : Filterbank lower bound
291- upper : Filterbank upper bound
300+ A : float
301+ Lower frame bound of the filter bank.
302+ B : float
303+ Upper frame bound of the filter bank.
292304
293305 Examples
294306 --------
295- >>> import numpy as np
296307 >>> from pygsp import graphs, filters
297308 >>> G = graphs.Logo()
298- >>> MH = filters.MexicanHat(G)
299- >>> bounds = MH.filterbank_bounds()
300- >>> print('lower={:.3f}, upper={:.3f}'.format(bounds[0], bounds[1]))
301- lower=0.178, upper=0.270
309+ >>> G.estimate_lmax()
310+ >>> f = filters.MexicanHat(G)
311+
312+ Bad estimation:
313+
314+ >>> A, B = f.estimate_frame_bounds(min=1, max=20, N=100)
315+ >>> print('A={:.3f}, B={:.3f}'.format(A, B))
316+ A=0.126, B=0.270
317+
318+ Better estimation:
319+
320+ >>> A, B = f.estimate_frame_bounds()
321+ >>> print('A={:.3f}, B={:.3f}'.format(A, B))
322+ A=0.177, B=0.270
323+
324+ Best estimation:
325+
326+ >>> G.compute_fourier_basis()
327+ >>> A, B = f.estimate_frame_bounds(use_eigenvalues=True)
328+ >>> print('A={:.3f}, B={:.3f}'.format(A, B))
329+ A=0.178, B=0.270
330+
331+ The Itersine filter bank defines a tight frame:
332+
333+ >>> f = filters.Itersine(G)
334+ >>> G.compute_fourier_basis()
335+ >>> A, B = f.estimate_frame_bounds(use_eigenvalues=True)
336+ >>> print('A={:.3f}, B={:.3f}'.format(A, B))
337+ A=1.000, B=1.000
302338
303339 """
304- if bounds :
305- xmin , xmax = bounds
306- rng = np .linspace (xmin , xmax , N )
340+
341+ if max is None :
342+ max = self .G .lmax
343+
344+ if use_eigenvalues :
345+ x = self .G .e
307346 else :
308- rng = self . G . e
347+ x = np . linspace ( min , max , N )
309348
310- sum_filters = np .sum (np .abs (np .power (self .evaluate (rng ), 2 )), axis = 0 )
349+ sum_filters = np .sum (np .abs (np .power (self .evaluate (x ), 2 )), axis = 0 )
311350
312- return np .min (sum_filters ), np .max (sum_filters )
351+ return sum_filters .min (), sum_filters .max ()
313352
314353 def filterbank_matrix (self ):
315354 r"""
0 commit comments