Mercurial > hg > octave-nkf
annotate scripts/signal/durbinlevinson.m @ 17530:0f45d9dd8107
test: Fix 4 failing plot demos.
* scripts/plot/legend.m: Demo #11, use 'h' for returned handle.
* scripts/plot/plot.m: Fix typo "lenths" -> "lengths".
* scripts/plot/ribbon.m: Remove unnecessary call to meshgrid now
that sombrero returns meshgridded data.
* scripts/plot/trimesh.m: Set colormap so plot is always reproducible.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 01 Oct 2013 15:39:20 -0700 |
parents | 1c89599167a6 |
children | d63878346099 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1 ## Copyright (C) 1995-2012 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) 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 |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
3191 | 18 |
3449 | 19 ## -*- texinfo -*- |
20 ## @deftypefn {Function File} {} durbinlevinson (@var{c}, @var{oldphi}, @var{oldv}) | |
21 ## Perform one step of the Durbin-Levinson algorithm. | |
3191 | 22 ## |
6547 | 23 ## The vector @var{c} specifies the autocovariances @code{[gamma_0, @dots{}, |
3449 | 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. | |
3191 | 27 ## |
3449 | 28 ## If @var{oldphi} and @var{oldv} are omitted, all steps from 1 to |
29 ## @var{t} of the algorithm are performed. | |
30 ## @end deftypefn | |
3426 | 31 |
3457 | 32 ## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at> |
33 ## Description: Perform one step of the Durbin-Levinson algorithm | |
3426 | 34 |
3191 | 35 function [newphi, newv] = durbinlevinson (c, oldphi, oldv) |
3426 | 36 |
3457 | 37 if (! ((nargin == 1) || (nargin == 3))) |
6046 | 38 print_usage (); |
3191 | 39 endif |
3426 | 40 |
3457 | 41 if (columns (c) > 1) |
8507 | 42 c = c'; |
3191 | 43 endif |
44 | |
45 newphi = 0; | |
46 newv = 0; | |
3426 | 47 |
3191 | 48 if (nargin == 3) |
3426 | 49 |
3191 | 50 t = length (oldphi) + 1; |
3426 | 51 |
3191 | 52 if (length (c) < t+1) |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
53 error ("durbinlevinson: C too small"); |
3191 | 54 endif |
3426 | 55 |
3191 | 56 if (oldv == 0) |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
57 error ("durbinlevinson: OLDV = 0"); |
3191 | 58 endif |
3426 | 59 |
3457 | 60 if (rows (oldphi) > 1) |
3191 | 61 oldphi = oldphi'; |
62 endif | |
3426 | 63 |
3191 | 64 newphi = zeros (1, t); |
3457 | 65 newphi(1) = (c(t+1) - oldphi * c(2:t)) / oldv; |
3191 | 66 for i = 2 : t |
67 newphi(i) = oldphi(i-1) - newphi(1) * oldphi(t-i+1); | |
68 endfor | |
3457 | 69 newv = (1 - newphi(1)^2) * oldv; |
3426 | 70 |
3191 | 71 elseif(nargin == 1) |
3426 | 72 |
3191 | 73 tt = length (c)-1; |
74 oldphi = c(2) / c(1); | |
3457 | 75 oldv = (1 - oldphi^2) * c(1); |
3426 | 76 |
3191 | 77 for t = 2 : tt |
3426 | 78 |
3191 | 79 newphi = zeros (1, t); |
3457 | 80 newphi(1) = (c(t+1) - oldphi * c(2:t)) / oldv; |
3191 | 81 for i = 2 : t |
3426 | 82 newphi(i) = oldphi(i-1) - newphi(1) * oldphi(t-i+1); |
3191 | 83 endfor |
3457 | 84 newv = (1 - newphi(1)^2) * oldv; |
3426 | 85 |
3191 | 86 oldv = newv; |
87 oldphi = newphi; | |
3426 | 88 |
3191 | 89 endfor |
3426 | 90 |
3191 | 91 endif |
92 | |
93 endfunction | |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
94 |