Mercurial > hg > octave-nkf
annotate scripts/signal/arch_rnd.m @ 20511:eca5aa3225f4
imshow.m: Add support for 'parent' property (bug #45473).
* imshow.m: Add cell variable prop_val_args{:} when calling image or imagesc.
Populate prop_val_args with {"parent", hparent} when "parent" argument given
to imshow. Remove code commented out in 2015/05/1 which has not caused any
problems. Add warning that arguments "border" and "reduce" are not supported.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 05 Jul 2015 13:55:56 -0700 |
parents | 83792dd9bcc1 |
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 Kurt Hornik |
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 -*- |
3500 | 20 ## @deftypefn {Function File} {} arch_rnd (@var{a}, @var{b}, @var{t}) |
20375
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20038
diff
changeset
|
21 ## 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:
20038
diff
changeset
|
22 ## CH coefficients @var{a}. |
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20038
diff
changeset
|
23 ## |
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
20038
diff
changeset
|
24 ## The result @math{y(t)} follows the model |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
25 ## @c Set example in small font to prevent overfull line |
3191 | 26 ## |
7031 | 27 ## @smallexample |
3499 | 28 ## y(t) = b(1) + b(2) * y(t-1) + @dots{} + b(lb) * y(t-lb+1) + e(t), |
7031 | 29 ## @end smallexample |
3449 | 30 ## |
31 ## @noindent | |
3499 | 32 ## where @math{e(t)}, given @var{y} up to time @math{t-1}, is |
33 ## @math{N(0, h(t))}, with | |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
9245
diff
changeset
|
34 ## @c Set example in small font to prevent overfull line |
3449 | 35 ## |
7031 | 36 ## @smallexample |
3499 | 37 ## h(t) = a(1) + a(2) * e(t-1)^2 + @dots{} + a(la) * e(t-la+1)^2 |
7031 | 38 ## @end smallexample |
3449 | 39 ## @end deftypefn |
3191 | 40 |
5428 | 41 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> |
3457 | 42 ## Description: Simulate an ARCH process |
3191 | 43 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10846
diff
changeset
|
44 function y = arch_rnd (a, b, t) |
3426 | 45 |
3191 | 46 if (nargin != 3) |
6046 | 47 print_usage (); |
3191 | 48 endif |
3426 | 49 |
3457 | 50 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
|
51 error ("arch_rnd: A and B must both be scalars or vectors"); |
3191 | 52 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
|
53 if (! (isscalar (t) && (t > 0) && (rem (t, 1) == 0))) |
3457 | 54 error ("arch_rnd: T must be a positive integer"); |
3191 | 55 endif |
3426 | 56 |
3457 | 57 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
|
58 error ("arch_rnd: A(1) must be positive"); |
3191 | 59 endif |
60 ## perhaps add a test for the roots of a(z) here ... | |
3426 | 61 |
3191 | 62 la = length (a); |
63 a = reshape (a, 1, la); | |
64 if (la == 1) | |
65 a = [a, 0]; | |
20441
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
20375
diff
changeset
|
66 la += 1; |
3191 | 67 endif |
7436 | 68 |
3191 | 69 lb = length (b); |
70 b = reshape (b, 1, lb); | |
71 if (lb == 1) | |
72 b = [b, 0]; | |
20441
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
20375
diff
changeset
|
73 lb += 1; |
3191 | 74 endif |
20038
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
75 m = max ([la, lb]); |
3426 | 76 |
20038
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
77 e = zeros (t, 1); |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
78 h = zeros (t, 1); |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
79 y = zeros (t, 1); |
3426 | 80 |
3191 | 81 h(1) = a(1); |
82 e(1) = sqrt (h(1)) * randn; | |
83 y(1) = b(1) + e(1); | |
3426 | 84 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10846
diff
changeset
|
85 for t = 2:m |
3238 | 86 ta = min ([t, la]); |
7436 | 87 h(t) = a(1) + a(2:ta) * e(t-ta+1:t-1).^2; |
3191 | 88 e(t) = sqrt (h(t)) * randn; |
3238 | 89 tb = min ([t, lb]); |
7436 | 90 y(t) = b(1) + b(2:tb) * y(t-tb+1:t-1) + e(t); |
3191 | 91 endfor |
7436 | 92 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10846
diff
changeset
|
93 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
|
94 for t = m+1:t |
7436 | 95 h(t) = a(1) + a(2:la) * e(t-la+1:t-1).^2; |
3191 | 96 e(t) = sqrt (h(t)) * randn; |
7436 | 97 y(t) = b(1) + b(2:lb) * y(t-tb+1:t-1) + e(t); |
3191 | 98 endfor |
99 endif | |
3426 | 100 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10846
diff
changeset
|
101 y = y(1:t); |
3426 | 102 |
3191 | 103 endfunction |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
104 |