@@ -272,44 +272,79 @@ def tighten(self):
272
272
"""
273
273
raise NotImplementedError
274
274
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 ):
276
277
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.
278
283
279
284
Parameters
280
285
----------
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.
287
297
288
298
Returns
289
299
-------
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.
292
304
293
305
Examples
294
306
--------
295
- >>> import numpy as np
296
307
>>> from pygsp import graphs, filters
297
308
>>> 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
+ >>> A, B = f.estimate_frame_bounds(min=1, max=20, N=100)
314
+ >>> print('A={:.3f}, B={:.3f}'.format(A, B))
315
+ A=0.126, B=0.270
316
+
317
+ Better estimation:
318
+ >>> A, B = f.estimate_frame_bounds()
319
+ >>> print('A={:.3f}, B={:.3f}'.format(A, B))
320
+ A=0.177, B=0.270
321
+
322
+ Best estimation:
323
+ >>> G.compute_fourier_basis()
324
+ >>> A, B = f.estimate_frame_bounds(use_eigenvalues=True)
325
+ >>> print('A={:.3f}, B={:.3f}'.format(A, B))
326
+ A=0.178, B=0.270
327
+
328
+ The Itersine filter bank defines a tight frame:
329
+ >>> f = filters.Itersine(G)
330
+ >>> G.compute_fourier_basis()
331
+ >>> A, B = f.estimate_frame_bounds(use_eigenvalues=True)
332
+ >>> print('A={:.3f}, B={:.3f}'.format(A, B))
333
+ A=1.000, B=1.000
302
334
303
335
"""
304
- if bounds :
305
- xmin , xmax = bounds
306
- rng = np .linspace (xmin , xmax , N )
336
+
337
+ if max is None :
338
+ max = self .G .lmax
339
+
340
+ if use_eigenvalues :
341
+ x = self .G .e
307
342
else :
308
- rng = self . G . e
343
+ x = np . linspace ( min , max , N )
309
344
310
- sum_filters = np .sum (np .abs (np .power (self .evaluate (rng ), 2 )), axis = 0 )
345
+ sum_filters = np .sum (np .abs (np .power (self .evaluate (x ), 2 )), axis = 0 )
311
346
312
- return np .min (sum_filters ), np .max (sum_filters )
347
+ return sum_filters .min (), sum_filters .max ()
313
348
314
349
def filterbank_matrix (self ):
315
350
r"""
0 commit comments