Mercurial > octave-nkf
annotate scripts/signal/durbinlevinson.m @ 20654:b65888ec820e draft default tip gccjit
dmalcom gcc jit import
author | Stefan Mahr <dac922@gmx.de> |
---|---|
date | Fri, 27 Feb 2015 16:59:36 +0100 |
parents | f1d0f506ee78 |
children |
rev | line source |
---|---|
19731
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19074
diff
changeset
|
1 ## Copyright (C) 1995-2015 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}) | |
19074
0850b5212619
doc: Add @nospell macro around proper names in documentation.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
21 ## Perform one step of the @nospell{Durbin-Levinson} algorithm. |
3191 | 22 ## |
20200
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
23 ## The vector @var{c} specifies the autocovariances |
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
24 ## @code{[gamma_0, @dots{}, gamma_t]} from lag 0 to @var{t}, @var{oldphi} |
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
25 ## specifies the coefficients based on @var{c}(@var{t}-1) and @var{oldv} |
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
26 ## specifies the corresponding error. |
3191 | 27 ## |
20200
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
28 ## If @var{oldphi} and @var{oldv} are omitted, all steps from 1 to @var{t} of |
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
29 ## the algorithm are performed. |
3449 | 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 |
19867
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
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 |