7017
|
1 ## Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2005, |
|
2 ## 2007 Friedrich Leisch |
3426
|
3 ## |
3922
|
4 ## This file is part of Octave. |
|
5 ## |
|
6 ## Octave is free software; you can redistribute it and/or modify it |
|
7 ## under the terms of the GNU General Public License as published by |
7016
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
|
9 ## your option) any later version. |
3426
|
10 ## |
3922
|
11 ## Octave is distributed in the hope that it will be useful, but |
3191
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3426
|
14 ## General Public License for more details. |
|
15 ## |
3191
|
16 ## You should have received a copy of the GNU General Public License |
7016
|
17 ## along with Octave; see the file COPYING. If not, see |
|
18 ## <http://www.gnu.org/licenses/>. |
3191
|
19 |
3449
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} spectral_adf (@var{c}, @var{win}, @var{b}) |
|
22 ## Return the spectral density estimator given a vector of |
|
23 ## autocovariances @var{c}, window name @var{win}, and bandwidth, |
|
24 ## @var{b}. |
3426
|
25 ## |
3449
|
26 ## The window name, e.g., @code{"triangle"} or @code{"rectangle"} is |
|
27 ## used to search for a function called @code{@var{win}_sw}. |
3426
|
28 ## |
3449
|
29 ## If @var{win} is omitted, the triangle window is used. If @var{b} is |
|
30 ## omitted, @code{1 / sqrt (length (@var{x}))} is used. |
|
31 ## @end deftypefn |
3426
|
32 |
3457
|
33 ## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at> |
|
34 ## Description: Spectral density estimation |
3426
|
35 |
3191
|
36 function retval = spectral_adf (c, win, b) |
3426
|
37 |
3191
|
38 cr = length (c); |
3426
|
39 |
3191
|
40 if (columns (c) > 1) |
|
41 c=c'; |
|
42 endif |
|
43 |
|
44 if (nargin < 3) |
|
45 b = 1 / ceil (sqrt (cr)); |
|
46 endif |
|
47 |
|
48 if (nargin == 1) |
|
49 w = triangle_lw (cr, b); |
|
50 else |
4348
|
51 win = str2func (strcat (win, "_lw")); |
3191
|
52 w = feval (win, cr, b); |
|
53 endif |
3426
|
54 |
3191
|
55 c = c .* w; |
3426
|
56 |
3191
|
57 retval = 2 * real (fft (c)) - c(1); |
3238
|
58 retval = [(zeros (cr, 1)), retval]; |
3374
|
59 retval(:, 1) = (0 : cr-1)' / cr; |
3426
|
60 |
3191
|
61 endfunction |
|
62 |
|
63 |
3426
|
64 |
|
65 |
|
66 |