Mercurial > hg > octave-nkf
annotate scripts/signal/diffpara.m @ 11469:c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 09 Jan 2011 12:41:21 -0800 |
parents | 3140cb7a05a1 |
children | 1740012184f9 |
rev | line source |
---|---|
7017 | 1 ## Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2005, 2006, |
2 ## 2007 Friedrich Leisch | |
3426 | 3 ## |
3922 | 4 ## This file is part of Octave. |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7 ## under the terms of the GNU General Public License as published by | |
7016 | 8 ## the Free Software Foundation; either version 3 of the License, or (at |
9 ## your option) any later version. | |
3426 | 10 ## |
3922 | 11 ## Octave is distributed in the hope that it will be useful, but |
3191 | 12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
3426 | 14 ## General Public License for more details. |
15 ## | |
3191 | 16 ## You should have received a copy of the GNU General Public License |
7016 | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | |
3191 | 19 |
3449 | 20 ## -*- texinfo -*- |
6547 | 21 ## @deftypefn {Function File} {[@var{d}, @var{dd}] =} diffpara (@var{x}, @var{a}, @var{b}) |
3449 | 22 ## Return the estimator @var{d} for the differencing parameter of an |
3191 | 23 ## integrated time series. |
24 ## | |
3499 | 25 ## The frequencies from @math{[2*pi*a/t, 2*pi*b/T]} are used for the |
26 ## estimation. If @var{b} is omitted, the interval | |
27 ## @math{[2*pi/T, 2*pi*a/T]} is used. If both @var{b} and @var{a} are | |
28 ## omitted then @math{a = 0.5 * sqrt (T)} and @math{b = 1.5 * sqrt (T)} | |
29 ## is used, where @math{T} is the sample size. If @var{x} is a matrix, | |
30 ## the differencing parameter of each column is estimated. | |
3191 | 31 ## |
3449 | 32 ## The estimators for all frequencies in the intervals |
3499 | 33 ## described above is returned in @var{dd}. The value of @var{d} is |
34 ## simply the mean of @var{dd}. | |
3191 | 35 ## |
10791
3140cb7a05a1
Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
36 ## Reference: P.J. Brockwell & R.A. Davis. @cite{Time Series: |
3140cb7a05a1
Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
37 ## Theory and Methods}. Springer 1987. |
3449 | 38 ## @end deftypefn |
3426 | 39 |
3457 | 40 ## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at> |
41 ## Description: Estimate the fractional differencing parameter | |
3191 | 42 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
43 function [d, dd] = diffpara (x, a, b) |
3426 | 44 |
3191 | 45 if ((nargin < 1) || (nargin > 3)) |
6046 | 46 print_usage (); |
3191 | 47 else |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
48 if (isvector (x)) |
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
49 n = length (x); |
3191 | 50 k = 1; |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
51 x = reshape (x, n, 1); |
3191 | 52 else |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
53 [n, k] = size(x); |
3191 | 54 endif |
55 if (nargin == 1) | |
56 a = 0.5 * sqrt (n); | |
57 b = 1.5 * sqrt (n); | |
58 elseif (nargin == 2) | |
59 b = a; | |
60 a = 1; | |
61 endif | |
62 endif | |
3426 | 63 |
4030 | 64 if (! (isscalar (a) && isscalar (b))) |
3457 | 65 error ("diffpara: a and b must be scalars"); |
3191 | 66 endif |
3426 | 67 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
68 dd = zeros (b - a + 1, k); |
3426 | 69 |
3191 | 70 for l = 1:k |
3426 | 71 |
3191 | 72 w = 2 * pi * (1 : n-1) / n; |
3426 | 73 |
3457 | 74 x = 2 * log (abs (1 - exp (-i*w))); |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
75 y = log (periodogram (x(2:n,l))); |
3426 | 76 |
3191 | 77 x = center (x); |
78 y = center (y); | |
3426 | 79 |
3191 | 80 for m = a:b |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
81 dd(m-a+1) = - x(1:m) * y(1:m) / sumsq (x(1:m)); |
3191 | 82 endfor |
3426 | 83 |
3191 | 84 endfor |
3426 | 85 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
86 d = mean (dd); |
3426 | 87 |
3191 | 88 endfunction |
89 |