Mercurial > octave
annotate scripts/signal/arch_rnd.m @ 30564:796f54d4ddbf stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
In all .txi and .texi files except gpl.txi and gpl.texi in the
doc/liboctave and doc/interpreter directories, change the copyright
to "Octave Project Developers", the same as used for other source
files. Update copyright notices for 2022 (not done since 2019). For
gpl.txi and gpl.texi, change the copyright notice to be "Free Software
Foundation, Inc." and leave the date at 2007 only because this file
only contains the text of the GPL, not anything created by the Octave
Project Developers.
Add Paul Thomas to contributors.in.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 28 Dec 2021 18:22:40 -0500 |
parents | 7854d5752dd2 |
children | 5d3faba0342e |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
3 ## Copyright (C) 1995-2022 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
3426 | 7 ## |
3922 | 8 ## This file is part of Octave. |
9 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
3922 | 11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
3426 | 14 ## |
3922 | 15 ## Octave is distributed in the hope that it will be useful, but |
3191 | 16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
3426 | 19 ## |
3191 | 20 ## You should have received a copy of the GNU General Public License |
7016 | 21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
3191 | 25 |
3449 | 26 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20231
diff
changeset
|
27 ## @deftypefn {} {} arch_rnd (@var{a}, @var{b}, @var{t}) |
20165
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
28 ## Simulate an ARCH sequence of length @var{t} with AR coefficients @var{b} and |
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
29 ## CH coefficients @var{a}. |
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
30 ## |
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
31 ## The result @math{y(t)} follows the model |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
32 ## @c Set example in small font to prevent overfull line |
3191 | 33 ## |
7031 | 34 ## @smallexample |
3499 | 35 ## y(t) = b(1) + b(2) * y(t-1) + @dots{} + b(lb) * y(t-lb+1) + e(t), |
7031 | 36 ## @end smallexample |
3449 | 37 ## |
38 ## @noindent | |
3499 | 39 ## where @math{e(t)}, given @var{y} up to time @math{t-1}, is |
40 ## @math{N(0, h(t))}, with | |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
41 ## @c Set example in small font to prevent overfull line |
3449 | 42 ## |
7031 | 43 ## @smallexample |
3499 | 44 ## h(t) = a(1) + a(2) * e(t-1)^2 + @dots{} + a(la) * e(t-la+1)^2 |
7031 | 45 ## @end smallexample |
3449 | 46 ## @end deftypefn |
3191 | 47 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10846
diff
changeset
|
48 function y = arch_rnd (a, b, t) |
3426 | 49 |
3191 | 50 if (nargin != 3) |
6046 | 51 print_usage (); |
3191 | 52 endif |
3426 | 53 |
3457 | 54 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:
11469
diff
changeset
|
55 error ("arch_rnd: A and B must both be scalars or vectors"); |
3191 | 56 endif |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10846
diff
changeset
|
57 if (! (isscalar (t) && (t > 0) && (rem (t, 1) == 0))) |
3457 | 58 error ("arch_rnd: T must be a positive integer"); |
3191 | 59 endif |
3426 | 60 |
3457 | 61 if (! (a(1) > 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:
11469
diff
changeset
|
62 error ("arch_rnd: A(1) must be positive"); |
3191 | 63 endif |
64 ## perhaps add a test for the roots of a(z) here ... | |
3426 | 65 |
3191 | 66 la = length (a); |
67 a = reshape (a, 1, la); | |
68 if (la == 1) | |
69 a = [a, 0]; | |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
20165
diff
changeset
|
70 la += 1; |
3191 | 71 endif |
7436 | 72 |
3191 | 73 lb = length (b); |
74 b = reshape (b, 1, lb); | |
75 if (lb == 1) | |
76 b = [b, 0]; | |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
20165
diff
changeset
|
77 lb += 1; |
3191 | 78 endif |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
79 m = max ([la, lb]); |
3426 | 80 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
81 e = zeros (t, 1); |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
82 h = zeros (t, 1); |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
83 y = zeros (t, 1); |
3426 | 84 |
3191 | 85 h(1) = a(1); |
28892
3cac3ceb9629
maint: Use coding style with parentheses after function name to distinguish from a variable.
Rik <rik@octave.org>
parents:
27984
diff
changeset
|
86 e(1) = sqrt (h(1)) * randn (); |
3191 | 87 y(1) = b(1) + e(1); |
3426 | 88 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10846
diff
changeset
|
89 for t = 2:m |
3238 | 90 ta = min ([t, la]); |
7436 | 91 h(t) = a(1) + a(2:ta) * e(t-ta+1:t-1).^2; |
28892
3cac3ceb9629
maint: Use coding style with parentheses after function name to distinguish from a variable.
Rik <rik@octave.org>
parents:
27984
diff
changeset
|
92 e(t) = sqrt (h(t)) * randn (); |
3238 | 93 tb = min ([t, lb]); |
7436 | 94 y(t) = b(1) + b(2:tb) * y(t-tb+1:t-1) + e(t); |
3191 | 95 endfor |
7436 | 96 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10846
diff
changeset
|
97 if (t > m) |
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10846
diff
changeset
|
98 for t = m+1:t |
7436 | 99 h(t) = a(1) + a(2:la) * e(t-la+1:t-1).^2; |
28892
3cac3ceb9629
maint: Use coding style with parentheses after function name to distinguish from a variable.
Rik <rik@octave.org>
parents:
27984
diff
changeset
|
100 e(t) = sqrt (h(t)) * randn (); |
7436 | 101 y(t) = b(1) + b(2:lb) * y(t-tb+1:t-1) + e(t); |
3191 | 102 endfor |
103 endif | |
3426 | 104 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10846
diff
changeset
|
105 y = y(1:t); |
3426 | 106 |
3191 | 107 endfunction |