3191
|
1 ## Copyright (C) 1995, 1996, 1997 Friedrich Leisch |
3426
|
2 ## |
3191
|
3 ## This program is free software; you can redistribute it and/or modify |
|
4 ## it under the terms of the GNU General Public License as published by |
|
5 ## the Free Software Foundation; either version 2, or (at your option) |
|
6 ## any later version. |
3426
|
7 ## |
3191
|
8 ## This program is distributed in the hope that it will be useful, but |
|
9 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3426
|
11 ## General Public License for more details. |
|
12 ## |
3191
|
13 ## You should have received a copy of the GNU General Public License |
|
14 ## along with this file. If not, write to the Free Software Foundation, |
|
15 ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
16 |
3449
|
17 ## -*- texinfo -*- |
|
18 ## @deftypefn {Function File} {} hurst (@var{x}) |
|
19 ## Estimate the Hurst parameter of sample @var{x} via the rescaled range |
|
20 ## statistic. If @var{x} is a matrix, the parameter is estimated for |
|
21 ## every single column. |
|
22 ## @end deftypefn |
3191
|
23 |
|
24 ## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at> |
|
25 ## Description: Estimate the Hurst parameter |
3426
|
26 |
3191
|
27 function H = hurst (x) |
|
28 |
|
29 if (nargin != 1) |
|
30 usage ("hurst (x)"); |
|
31 endif |
|
32 |
|
33 if (is_scalar (x)) |
|
34 error ("hurst: x must not be a scalar") |
|
35 elseif is_vector (x) |
|
36 x = reshape (x, length (x), 1); |
|
37 end |
3426
|
38 |
3238
|
39 [xr, xc] = size (x); |
3191
|
40 |
|
41 s = std (x); |
|
42 w = cumsum (x - mean (x)); |
|
43 RS = (max(w) - min(w)) ./ s; |
|
44 H = log (RS) / log (xr); |
3426
|
45 |
3191
|
46 endfunction |