Mercurial > hg > octave-nkf
annotate scripts/signal/arma_rnd.m @ 19830:884e0c55d92c
Fix complex compare operation for issorted (bug #44071).
* Array-C.cc (nan_ascending_compare, nan_descending_compare): Fix typo where
comparison was made between x and x rather than between x and y.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 26 Jan 2015 15:32:49 -0800 |
parents | d63878346099 |
children | 4197fc428c7d |
rev | line source |
---|---|
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17338
diff
changeset
|
1 ## Copyright (C) 1995-2013 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} {} arma_rnd (@var{a}, @var{b}, @var{v}, @var{t}, @var{n}) | |
21 ## Return a simulation of the ARMA model | |
22 ## | |
23 ## @example | |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
24 ## @group |
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
25 ## x(n) = a(1) * x(n-1) + @dots{} + a(k) * x(n-k) |
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
26 ## + e(n) + b(1) * e(n-1) + @dots{} + b(l) * e(n-l) |
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
27 ## @end group |
3449 | 28 ## @end example |
3191 | 29 ## |
3449 | 30 ## @noindent |
31 ## in which @var{k} is the length of vector @var{a}, @var{l} is the | |
9072
bd8e388043c4
Cleanup documentation for signal.texi, image.texi, audio.texi
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
32 ## length of vector @var{b} and @var{e} is Gaussian white noise with |
3449 | 33 ## variance @var{v}. The function returns a vector of length @var{t}. |
3191 | 34 ## |
3449 | 35 ## The optional parameter @var{n} gives the number of dummy |
36 ## @var{x}(@var{i}) used for initialization, i.e., a sequence of length | |
37 ## @var{t}+@var{n} is generated and @var{x}(@var{n}+1:@var{t}+@var{n}) | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
38 ## is returned. If @var{n} is omitted, @var{n} = 100 is used. |
3449 | 39 ## @end deftypefn |
3426 | 40 |
3457 | 41 ## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at> |
42 ## Description: Simulate an ARMA process | |
3191 | 43 |
44 function x = arma_rnd (a, b, v, t, n) | |
45 | |
5568 | 46 if (nargin == 4) |
47 n = 100; | |
48 elseif (nargin == 5) | |
10483
7b5f706f3a83
typo in arma_rnd, by M. Vinyals
Jaroslav Hajek <highegg@gmail.com>
parents:
9072
diff
changeset
|
49 if (!isscalar (n)) |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
10483
diff
changeset
|
50 error ("arma_rnd: N must be a scalar"); |
3191 | 51 endif |
5568 | 52 else |
6046 | 53 print_usage (); |
5568 | 54 endif |
3191 | 55 |
5568 | 56 if ((min (size (a)) > 1) || (min (size (b)) > 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:
10483
diff
changeset
|
57 error ("arma_rnd: A and B must not be matrices"); |
5568 | 58 endif |
3426 | 59 |
5568 | 60 if (!isscalar (t)) |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
10483
diff
changeset
|
61 error ("arma_rnd: T must be a scalar"); |
5568 | 62 endif |
3426 | 63 |
5568 | 64 ar = length (a); |
65 br = length (b); | |
3426 | 66 |
5568 | 67 a = reshape (a, ar, 1); |
68 b = reshape (b, br, 1); | |
3426 | 69 |
8506 | 70 ## Apply our notational convention. |
71 a = [1; -a]; | |
5568 | 72 b = [1; b]; |
73 | |
74 n = min (n, ar + br); | |
3191 | 75 |
5568 | 76 e = sqrt (v) * randn (t + n, 1); |
77 | |
78 x = filter (b, a, e); | |
79 x = x(n + 1 : t + n); | |
3191 | 80 |
81 endfunction | |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
82 |