3191
|
1 ## Copyright (C) 1995, 1996, 1997 Friedrich Leisch |
3426
|
2 ## |
3922
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
3191
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
3426
|
9 ## |
3922
|
10 ## Octave is distributed in the hope that it will be useful, but |
3191
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3426
|
13 ## General Public License for more details. |
|
14 ## |
3191
|
15 ## You should have received a copy of the GNU General Public License |
3922
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
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 |