Mercurial > octave
annotate scripts/signal/yulewalker.m @ 23220:092078913d54
maint: Merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 22 Feb 2017 12:58:07 -0500 |
parents | ef4d915df748 3ac9f9ecfae5 |
children | 194eb4bd202b |
rev | line source |
---|---|
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
1 ## Copyright (C) 1995-2017 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 | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
8 ## (at 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 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## GNU General Public License for more details. |
3426 | 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 -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20165
diff
changeset
|
20 ## @deftypefn {} {[@var{a}, @var{v}] =} yulewalker (@var{c}) |
20165
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
21 ## Fit an AR (p)-model with Yule-Walker estimates given a vector @var{c} of |
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
22 ## autocovariances @code{[gamma_0, @dots{}, gamma_p]}. |
3426 | 23 ## |
20165
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
24 ## Returns the AR coefficients, @var{a}, and the variance of white noise, |
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
25 ## @var{v}. |
3449 | 26 ## @end deftypefn |
3426 | 27 |
3457 | 28 ## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at> |
29 ## Description: Fit AR model by Yule-Walker method | |
3426 | 30 |
3191 | 31 function [a, v] = yulewalker (c) |
3426 | 32 |
7125 | 33 if (nargin != 1) |
34 print_usage (); | |
35 endif | |
36 | |
3191 | 37 p = length (c) - 1; |
3426 | 38 |
3191 | 39 if (columns (c) > 1) |
40 c = c'; | |
41 endif | |
3426 | 42 |
3191 | 43 cp = c(2 : p+1); |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
44 CP = zeros (p, p); |
3426 | 45 |
3191 | 46 for i = 1:p |
47 for j = 1:p | |
48 CP (i, j) = c (abs (i-j) + 1); | |
49 endfor | |
50 endfor | |
3426 | 51 |
3191 | 52 a = inv (CP) * cp; |
53 v = c(1) - a' * cp; | |
3426 | 54 |
3191 | 55 endfunction |