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} {} durbinlevinson (@var{c}, @var{oldphi}, @var{oldv})
21 ## Perform one step of the Durbin-Levinson algorithm.
23 ## The vector @var{c} specifies the autocovariances @code{[gamma_0, @dots{},
24 ## gamma_t]} from lag 0 to @var{t}, @var{oldphi} specifies the
25 ## coefficients based on @var{c}(@var{t}-1) and @var{oldv} specifies the
26 ## corresponding error.
28 ## If @var{oldphi} and @var{oldv} are omitted, all steps from 1 to
29 ## @var{t} of the algorithm are performed.
32 ## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at>
33 ## Description: Perform one step of the Durbin-Levinson algorithm
35 function [newphi, newv] = durbinlevinson (c, oldphi, oldv)
37 if (! ((nargin == 1) || (nargin == 3)))
50 t = length (oldphi) + 1;
53 error ("durbinlevinson: C too small");
57 error ("durbinlevinson: OLDV = 0");
60 if (rows (oldphi) > 1)
64 newphi = zeros (1, t);
65 newphi(1) = (c(t+1) - oldphi * c(2:t)) / oldv;
67 newphi(i) = oldphi(i-1) - newphi(1) * oldphi(t-i+1);
69 newv = (1 - newphi(1)^2) * oldv;
75 oldv = (1 - oldphi^2) * c(1);
79 newphi = zeros (1, t);
80 newphi(1) = (c(t+1) - oldphi * c(2:t)) / oldv;
82 newphi(i) = oldphi(i-1) - newphi(1) * oldphi(t-i+1);
84 newv = (1 - newphi(1)^2) * oldv;