1 ## Copyright (C) 1995-2012 Friedrich Leisch
3 ## This file is part of Octave.
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
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {} spectral_adf (@var{c}, @var{win}, @var{b})
21 ## Return the spectral density estimator given a vector of
22 ## autocovariances @var{c}, window name @var{win}, and bandwidth,
25 ## The window name, e.g., @code{"triangle"} or @code{"rectangle"} is
26 ## used to search for a function called @code{@var{win}_sw}.
28 ## If @var{win} is omitted, the triangle window is used. If @var{b} is
29 ## omitted, @code{1 / sqrt (length (@var{x}))} is used.
32 ## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at>
33 ## Description: Spectral density estimation
35 function retval = spectral_adf (c, win, b)
44 b = 1 / ceil (sqrt (cr));
48 w = triangle_lw (cr, b);
50 win = str2func (cstrcat (win, "_lw"));
51 w = feval (win, cr, b);
56 retval = 2 * real (fft (c)) - c(1);
57 retval = [(zeros (cr, 1)), retval];
58 retval(:, 1) = (0 : cr-1)' / cr;