Mercurial > hg > octave-nkf
annotate scripts/signal/yulewalker.m @ 20815:a260a6acb70f
fix test failures introduced by a22d8a2eb0e5
* scripts/ode/private/integrate_adaptive.m: fix stepping backwards, fix
invocation of OutputFcn, fix text of some error messages
* scripts/ode/private/integrate_const.m: remove use of option OutputSave
* scripts/ode/private/integrate_n_steps.m: remove use of option OutputSave
author | Carlo de Falco <carlo.defalco@polimi.it> |
---|---|
date | Sun, 11 Oct 2015 23:09:01 +0200 |
parents | f1d0f506ee78 |
children |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17744
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} {[@var{a}, @var{v}] =} yulewalker (@var{c}) | |
20375
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
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:
19898
diff
changeset
|
22 ## autocovariances @code{[gamma_0, @dots{}, gamma_p]}. |
3426 | 23 ## |
20375
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
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:
19898
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 |
56 | |
57 |