./PaxHeaders.27446/tisean-0.2.3 0000644 0000000 0000000 00000000130 12563465360 012632 x ustar 00 30 mtime=1439591152.388480036
29 atime=1439591152.98447253
29 ctime=1439591152.98447253
tisean-0.2.3/ 0000755 0001750 0001750 00000000000 12563465360 013625 5 ustar 00josiah josiah 0000000 0000000 tisean-0.2.3/PaxHeaders.27446/NEWS 0000644 0000000 0000000 00000000131 12563465360 013252 x ustar 00 30 mtime=1439591152.304481094
30 atime=1439591152.304481094
29 ctime=1439591152.98447253
tisean-0.2.3/NEWS 0000644 0001750 0001750 00000006467 12563465360 014341 0 ustar 00josiah josiah 0000000 0000000 ===============================================================================
tisean-0.2.3 Release Date: 2015-08-14 Release Manager: Piotr Held
===============================================================================
** Added functions:
spikespec
spikeauto
** Modified all isnumeric to isreal since only real values are accepted by
the TISEAN package.
===============================================================================
tisean-0.2.2 Release Date: 2015-08-11 Release Manager: Piotr Held
===============================================================================
** Added functions:
surrogates
timerev
endtoend
===============================================================================
tisean-0.2.1 Release Date: 2015-07-03 Release Manager: Piotr Held
===============================================================================
** Removed deprecated functions:
addnoise
project
===============================================================================
tisean-0.2.0 Release Date: 2015-07-03 Release Manager: Piotr Held
===============================================================================
** Added new functions:
d2 c2d
av_d2 c2g
c2t c1
boxcount
** Minor types of improvements on rest of code.
===============================================================================
tisean-0.1.1 Release Date: 2015-06-16 Release Manager: Piotr Held
===============================================================================
** Added new functions:
lyap_k
lyap_r
lyap_spec
** delay
Fixed minor bug.
** Minor typos and code style improvements.
===============================================================================
tisean-0.1.0 Release Date: 2015-06-09 Release Manager: Piotr Held
===============================================================================
** Added new functions:
ikeda poincare
false_nearest ghkss
upo upoembed
lzo_gm lzo_run
lzo_test lfo_ar
lfo_run lfo_test
polynom xzero
rbf
** General maintenance changes
Removed compile time warnings, and change most of data allocation to
OCTAVE_LOCAL_BUFFER.
** The following have been deprecated:
project
===============================================================================
tisean-0.0.1 Release Date: 2015-05-15 Release Manager: Piotr Held
===============================================================================
** Added new functions:
mutual
spectrum
lazy
delay
pca
** addnoise
This function is now deprecated. It is no longer needed. But will be left
in the package for now.
** project
-- Bugfix: improved argument checking and documenation.
-- Wrote demo to show how this function works.
** henon
Optimized henon to run about 10 times faster.
===============================================================================
tisean-0.0.0 Release Date: Release Manager:
===============================================================================
Summary of important user-visible changes for tisiean 0.0.0:
** First package version, to get started
----------------------------------------------------------
tisean-0.2.3/PaxHeaders.27446/inst 0000644 0000000 0000000 00000000130 12563465360 013452 x ustar 00 30 mtime=1439591152.328480792
29 atime=1439591152.98447253
29 ctime=1439591152.98447253
tisean-0.2.3/inst/ 0000755 0001750 0001750 00000000000 12563465360 014602 5 ustar 00josiah josiah 0000000 0000000 tisean-0.2.3/inst/PaxHeaders.27446/delay.m 0000644 0000000 0000000 00000000131 12563465360 015004 x ustar 00 30 mtime=1439591152.316480943
30 atime=1439591152.316480943
29 ctime=1439591152.98447253
tisean-0.2.3/inst/delay.m 0000644 0001750 0001750 00000017237 12563465360 016070 0 ustar 00josiah josiah 0000000 0000000 ## Copyright (C) 1996-2015 Piotr Held
##
## This file is part of Octave.
##
## Octave is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public
## License as published by the Free Software Foundation;
## either version 3 of the License, or (at your option) any
## later version.
##
## Octave is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied
## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
## PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public
## License along with Octave; see the file COPYING. If not,
## see .
## -*- texinfo -*-
## @deftypefn{Function File} {@var{output} =} delay (@var{S})
## @deftypefnx{Function File} {@var{output} =} delay (@var{S}, @var{paramName}, @var{paramValue}, @dots{})
##
## Produce delay vectors
##
## @strong{Input}
##
## @table @var
## @item S
## This function always assumes that each time series is along the longer
## dimension of matrix @var{S}. It also assumes that every dimension (counting
## along the shorter dimension) of @var{S} is considered a component of the time
## series. So
## @example
##
## @var{S} = [[1:1000];[5:1004]]
##
## @end example
## would be considered a 2 component, 1000 element time series. Thus a typical
## call of 'henon' requires to choose one column of it. For instance:
## @example
##
## res = henon (5000);
## delay (res(:,1));
##
## @end example
## @end table
##
## @strong{Parameters}
##
## @table @var
## @item d
## Delay of the embedding vector. Can be either a vector of delays or a single
## value. Replaces flags '-d' and '-D' from TISEAN package. Example
## @example
##
## delay ([1:10], 'd', [2,4], 'm', 3)
##
## @end example
## This input will produce a delay vetor of the form
## @example
##
## (@var{x}(i),@var{x}(i-2),@var{x}(i-2-4))
##
## @end example
## It is important to remember to keep (lenght of 'D') == (value of flag '-M' from
## TISEAN == number of components of (@var{S})) whenever parameter 'D' is a vector.
## @item f
## The format of the embedding vector. Replaces flag '-F' from TISEAN. Example
## (assuming @var{a} and @var{b} are column vectors of the same length)
## @example
##
## delay ([@var{a},@var{b}], 'f', [3,2])
##
## @end example
## This input will produce a delay vector in the form
## @example
##
## (@var{a}(i),@var{a}(i-1),@var{a}(i-2),@var{b}(i),@var{b}(i-1))
##
## @end example
## @item m
## The embedding dimension. Replaces flag '-m' from TISEAN. Must be scalar
## integer. Also it needs to be integer multiple of number of components of
## (@var{S}) or else 'F' needs to be set. The following two examples are
## equivalent calls (@var{a}, @var{b}, @var{c} are column vectors of the same size)
## @example
##
## delay ([@var{a},@var{b},@var{c}], 'm', 9)
## delay ([@var{a},@var{b},@var{c}], 'f', [3,3,3])
##
## @end example
## @end table
##
## @strong{Output}
##
## Produces a matrix that contains delay vectors.
##
## @strong{Algorithms}
##
## The algorithms for this functions have been taken from the TISEAN package.
## @end deftypefn
## Author: Piotr Held .
## This function is based on delay of TISEAN 3.0.1
## https://github.com/heggus/Tisean"
function output = delay(S,varargin)
if (nargin < 1)
print_usage;
endif
if ((!ismatrix (S)) || (!isreal(S)))
error ('Octave:invalid-input-arg', "S is not a realmatrix");
endif
# Define default values for delay variables
indim = 1;
embdim = 2;
dimset = 0; # is not the default?
d = 1;
formatdelay = [indim,indim];
formatset = 0; # is not the default?
delaylist = d;
mdelayset = 0; # is not the default?
#### Parse the input
p = inputParser ();
p.FunctionName = "delay";
isPositiveIntScalar = @(x) isreal(x) && isscalar (x) && ...
(x > 0) && (x-round(x) == 0);
isPositiveIntVector = @(x) isreal(x) && isvector (x) && ...
all (x > 0) && all (x-round(x) == 0);
p.addParamValue ("d", d, isPositiveIntVector);
p.addParamValue ("m", embdim, isPositiveIntScalar);
p.addParamValue ("f", formatdelay, isPositiveIntVector);
p.parse (varargin{:});
# Assign inputs
embdim = p.Results.m;
embset = !ismember ('m',p.UsingDefaults);
# Placed old '-d' and '-D' flags into parameter 'd'
if (!ismember ('d',p.UsingDefaults))
d = p.Results.d;
if (length (d) > 1)
mdelayset = 1;
delaylist = p.Results.d;
endif
endif
formatdelay = p.Results.f;
formatset = !ismember('f', p.UsingDefaults);
# Correct S to always have more rows than columns
trnspsd = false;
if (rows (S) < columns (S))
S = S.';
trnspsd = true;
endif
# Assume all input is time series (ommit '-M' from original)
if (indim != columns (S))
dimset = 1;
indim = columns (S);
endif
# Input checking from original main()
# Check that if delays were not given the embeding dimension is a multiple of
# the input data dimension.
if (!formatset)
if (mod (embdim, indim))
error ('Octave:invalid-input-arg',...
["Inconsistent parameter 'm' and number of components of S.",...
" Please set parameter 'f'"]);
endif
formatdelay = ones(1,indim) * floor (embdim / indim);
endif
# Check that if delays were not given in a vector if so then
# create a default vector out of the given scalar delay.
if (!mdelayset)
delaylist = ones(1,sum (formatdelay)) * d;
endif
# Input checking from original create_delay_list()
# Check if the vector of delays given has the proper length
# that is that it is equal to the difference between the embedding
# dimension and the number of components.
if (mdelayset && (length (delaylist) != (embdim - indim)))
error ('Octave:invalid-input-arg', "Wrong number of delays");
endif
# Input checking from original create_format_list()
if (formatset)
# Check if the list of format delays is as long as the number
# components.
if (dimset && (length (formatdelay) != indim))
error ('Octave:invalid-input-arg',...
"Parameter 'f' length is not equal to the number of components");
endif
# Check if the sum of the formats is equal to the embedding dimensions
# if it is set.
if (embset && (sum (formatdelay) != embdim))
error ('Octave:invalid-input-arg',...
"The dimensions given in parameter 'm' and 'f' are not equal!");
endif
# If the number of input components is not set then set it.
if (!dimset)
indim = length (formatdelay);
endif
# If the embedding dimension is not set then set it.
if (!embset)
embdim = sum (formatdelay);
endif
endif
output = __delay__ (S, length(S), indim, formatdelay, delaylist);
if (trnspsd)
output = output.';
endif
endfunction
%!test delay(1:10,'m',3,'d',6);
%!test
%! a = 1:5;
%! d1 = 2:5;
%! d2 = 1:4;
%! d = delay (a);
%! assert (d, [d1;d2], 1e-6);
%!test
%! a = 1:5;
%! d1 = 3:5;
%! d2 = 1:3;
%! d = delay (a,'d',2);
%! assert (d, [d1;d2], 1e-6);
%!test
%! a = 1:10;
%! dg = [3 1 3 1;4 2 4 2;5 3 5 3;6 4 6 4;7 5 7 5;8 6 8 6;9 7 9 7;10 8 10 8];
%! d = delay ([a;a].','d',2,'m',4);
%! assert (d, dg, 1e-6);
%!test
%! a = 1:10;
%! dg = [3 2 3 1;4 3 4 2;5 4 5 3;6 5 6 4;7 6 7 5;8 7 8 6;9 8 9 7;10 9 10 8];
%! d = delay ([a;a].','d',[1 2],'m',4);
%! assert (d, dg, 1e-6);
%!test
%! a = 1:10;
%! dg = [4 3 1;5 4 2;6 5 3;7 6 4;8 7 5;9 8 6;10 9 7];
%! d = delay (a.','d',[1 2],'m',3);
%! assert (d, dg, 1e-6);
%!test
%! a = 1:10;
%! dg = [5 5 3 1; 6 6 4 2; 7 7 5 3; 8 8 6 4; 9 9 7 5; 10 10 8 6];
%! d = delay ([a;a].','d',2,'f',[1,3],'m',4);
%! assert (d, dg, 1e-6);
tisean-0.2.3/inst/PaxHeaders.27446/polynom.m 0000644 0000000 0000000 00000000131 12563465360 015403 x ustar 00 30 mtime=1439591152.324480842
30 atime=1439591152.324480842
29 ctime=1439591152.98447253
tisean-0.2.3/inst/polynom.m 0000644 0001750 0001750 00000014336 12563465360 016464 0 ustar 00josiah josiah 0000000 0000000 ## Copyright (C) 1996-2015 Piotr Held
##
## This file is part of Octave.
##
## Octave is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public
## License as published by the Free Software Foundation;
## either version 3 of the License, or (at your option) any
## later version.
##
## Octave is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied
## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
## PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public
## License along with Octave; see the file COPYING. If not,
## see .
## -*- texinfo -*-
## @deftypefn{Function File} {[@var{pars}, @var{forecast}] =} rbf (@var{X})
## @deftypefnx{Function File} {[@var{pars}, @var{forecast}] =} rbf (@var{X}, @var{paramName}, @var{paramValue}, @dots{})
##
## Models the data making a polynomial ansatz.
##
## @strong{Input}
##
## @table @var
## @item X
## Must be realvector. The output will be alligned with the input.
## @end table
##
## @strong{Parameters}
##
## @table @var
## @item m
## The embedding dimension. Synonymous with flag '-m' from TISEAN
## [default = 2].
## @item d
## Delay used for embedding [default = 1].
## @item p
## Order of the polynomial [default = 2].
## @item n
## Number of points for the fit. The other points are used to estimate
## the out of sample error [default = length (@var{X})].
## @item l
## The length of the predicted series [default = 0].
## @end table
##
## @strong{Output}
##
## @table @var
## @item pars
## This structure contains parameters used for the fit. It has the following
## fields:
## @itemize @bullet
## @item
## free - contains the number of free parameters of the fit
## @item
## norm - contains the norm used for the fit
## @item
## coeffs - contains the coefficients used for the fit
## @item
## err - err(1) is the in sample error, and err(2) is the out of sample error
## (if it exists)
## @end itemize
## @item forecast
## Contains the forecasted points. It's length is equal to the value of
## parameter @var{l}
## @end table
##
## @seealso{demo polynom}
##
## @strong{Algorithms}
##
## The algorithms for this functions have been taken from the TISEAN package.
## @end deftypefn
## Author: Piotr Held .
## This function is based on polynom of TISEAN 3.0.1
## https://github.com/heggus/Tisean"
function [pars, forecast] = polynom (X, varargin)
# Initial input validation
if (nargin < 1 || nargout > 2)
print_usage;
endif
if ((isvector (X) == false) || (isreal(X) == false))
error ('Octave:invalid-input-arg', "X must be a realvector");
endif
# Default parameters
embdim = 2;
delay = 1;
degree = 2;
insample = length (X);
clength = 0;
#### Parse the input
p = inputParser ();
p.FunctionName = "polynom";
isPositiveIntScalar = @(x) isreal(x) && isscalar (x) && ...
(x > 0) && (x-round(x) == 0);
isNonNegativeIntScalar = @(x) isPositiveIntScalar (x) || (length (x) == 1 ...
&&(x == 0));
p.addParamValue ("m", embdim, isPositiveIntScalar);
p.addParamValue ("d", delay, isPositiveIntScalar);
p.addParamValue ("p", degree, isPositiveIntScalar);
p.addParamValue ("n", insample, isPositiveIntScalar);
p.addParamValue ("l", clength, isNonNegativeIntScalar);
p.parse (varargin{:});
# Assign inputs
embdim = p.Results.m;
delay = p.Results.d;
degree = p.Results.p;
insample = p.Results.n;
clength = p.Results.l;
# Input corrections from main ()
if (insample > length (X))
warning ('Octave:tisean', "Parameter 'n' was too large, it has been \
reduced to: %d", length (X));
insample = length (X);
endif
# Correct X to always have more rows than columns
trnspsd = false;
if (rows (X) < columns (X))
X = X.';
trnspsd = true;
endif
[free_par, fit_norm, coeffs, sample_err, forecast] = ...
__polynom__ (X, embdim, delay, degree, insample, clength);
if (trnspsd)
free_par = free_par.';
fit_norm = fit_norm.';
coeffs = coeffs.';
sample_err = sample_err.';
forecast = forecast.';
endif
pars = struct ("free",free_par, "norm",fit_norm,"coeffs",coeffs, ...
"err", sample_err);
endfunction
%!demo
%! idx = (1:2500).';
%! # sin_saw is a sinusoid multiplied by a saw function
%! sin_saw = (5 + mod (idx, 165) ./15) .* sin (idx.* 2 * pi /32);
%!
%! forc_no = 170; %Number of forecasted points
%! [p,forecast] = polynom (sin_saw(1:end-forc_no), 'm', 2, 'd', 6, 'p', 4,
%! 'n',length(idx)-forc_no, 'l',forc_no);
%!
%! plot (idx(end-forc_no+1:end), sin_saw(end-forc_no+1:end),'b',...
%! idx(end-forc_no+1:end), forecast,'r.')
%! legend ('Actual Data', 'Forecasted Data')
%! axis tight
%!###############################################################
%!shared tisean_res
%! free_par = 15;
%! fit_norm = 7.288850e-01;
%! coeffs = [0 0 0 0 1.069020e+00;0 0 0 1 1.148981e-02;0 0 0 2 8.774236e-03;0 0 1 0 2.917788e-02;0 0 1 1 -2.070487e-02;0 0 2 0 2.716510e-02;0 1 0 0 -1.946794e-01;0 1 0 1 2.836742e-02;0 1 1 0 2.224498e-02;0 2 0 0 6.323062e-03;1 0 0 0 -1.384873e-01;1 0 0 1 9.227327e-03;1 0 1 0 -1.296314e-02;1 1 0 0 1.344875e-01;2 0 0 0 -1.325876e+00];
%! sample_err = [1.736542e-01;1.811800e-01];
%! forecast = [5.943424e-01; 4.346730e-01; 8.785541e-01; -3.759484e-02; 9.668226e-01; -2.578617e-01; 9.175962e-01; -1.684470e-01; 1.092976e+00; -6.234285e-01; 7.463370e-01; 2.116272e-01; 1.016354e+00; -4.107574e-01; 1.056590e+00];
%! tisean_res = {free_par, fit_norm, coeffs, sample_err, forecast};
%!test
%! hen = henon (1000);
%! hen = hen(:,1);
%! [pars,forc] = polynom (hen, 'm',4,'d',4,'p',2,'n',800,'l',15);
%! assert ({pars.free, pars.norm,pars.coeffs,pars.err,forc}, ...
%! tisean_res, -1e-6);
%% Check if by default the cast does not take place
%!test
%! [p,f] = polynom(henon(100)(:,1));
%! assert (f, []);
%% Check for matrix singularity error
%!error polynom (1:10);
%% ensure input correction warnings are called
%% they are promoted to errors so that the program does not do computation
%!error warning("error","Octave:tisean"); polynom (1:10, 'n',11);
tisean-0.2.3/inst/PaxHeaders.27446/poincare.m 0000644 0000000 0000000 00000000131 12563465360 015506 x ustar 00 30 mtime=1439591152.324480842
30 atime=1439591152.324480842
29 ctime=1439591152.98447253
tisean-0.2.3/inst/poincare.m 0000644 0001750 0001750 00000015572 12563465360 016572 0 ustar 00josiah josiah 0000000 0000000 ## Copyright (C) 1996-2015 Piotr Held
##
## This file is part of Octave.
##
## Octave is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public
## License as published by the Free Software Foundation;
## either version 3 of the License, or (at your option) any
## later version.
##
## Octave is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied
## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
## PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public
## License along with Octave; see the file COPYING. If not,
## see .
## -*- texinfo -*-
## @deftypefn{Function File} {@var{output} =} poincare (@var{X})
## @deftypefnx{Function File} {@var{output} =} poincare (@var{X}, @var{m}, @var{paramName}, @var{paramValue}, @dots{})
## @deftypefnx{Function File} {@var{output} =} poincare (@dots{}, 'FromAbove', @dots{})
##
## Make a Poincare section for time continuous scalar data sets
## along one of the coordinates of the embedding vector.
##
## @strong{Input}
##
## @table @var
## @item X
## Must be realvector. If it is a row vector then the output will
## be a matrix that consists of row vectors as well.
## @end table
##
##
## @strong {Parameters}
##
## @table @var
## @item m
## The embedding dimension used. It is synonymous to
## flag '-m' from TISEAN [default = 2].
## @item d
## Delay used for the embedding [default = 1].
## @item q
## Component for the crossing [default = value of parameter 'm' (last one)].
## @item a
## @end table
##
## @strong {Switch}
##
## @table @var
## @item FromAbove
## If this switch is set the crossing will occur from above, instead of
## from below. This is equivalent to setting flag '-C1' from TISEAN.
## @end table
##
## @strong{Output}
##
## The output consists of the as many components as the value of parameter
## @var{m} (columns or rows depending on input). The first @code{M-1} are
## the coordinates of the vector at the crossing and the last component
## is the time between the last two crossings.
##
## @strong{Algorithms}
##
## The algorithms for this functions have been taken from the TISEAN package.
## @end deftypefn
## Author: Piotr Held .
## This function is based on poincare of TISEAN 3.0.1
## https://github.com/heggus/Tisean"
function output = poincare (X, varargin)
# Initial input validation
if (nargin < 1)
print_usage;
endif
if ((isvector (X) == false) || (isreal(X) == false))
error ('Octave:invalid-input-arg', "X must be a realvector");
endif
# Default values
embdim = 2;
delay = 1;
comp = embdim;
where = sum (X) / length (X);
#### Parse the input
p = inputParser ();
p.FunctionName = "poincare";
isPositiveIntScalar = @(x) isreal(x) && isscalar (x) && ...
(x > 0) && (x-round(x) == 0);
isNumericScalar = @(x) isreal(x) && isscalar (x);
p.addParamValue ("m", embdim, isPositiveIntScalar);
p.addParamValue ("d", delay, isPositiveIntScalar);
p.addParamValue ("q", comp, isPositiveIntScalar);
p.addParamValue ("a", where, isNumericScalar);
p.addSwitch ("FromAbove");
p.parse (varargin{:});
# Assign inputs
embdim = p.Results.m;
dimset = !ismember ('m', p.UsingDefaults);
delay = p.Results.d;
comp = p.Results.q;
compset = !ismember ('q', p.UsingDefaults);
where = p.Results.a;
whereset = !ismember ('a', p.UsingDefaults);
direction = p.Results.FromAbove;
# If the component for the crossing is not set and the
# embedding dimension is set then assign then make the component
# for the crossing the last one.
if (dimset && !compset)
comp=embdim;
endif
# Input validation from main()
# Check if the component for the crossing is not larger
# than the embedding dimension.
if (comp > embdim)
error ('Octave:invalid-input-arg', ...
"Component for the crossing is larger than dimension");
endif
# Check whether the set value of where is bigger
# or smaller of the largest or smallest element of X
if (whereset && ((where < min (X)) || (where > max (X))))
error ('Octave:invalid-input-arg', ...
"You want to cut outside the data interval which is [%e, %e]", ...
min, max);
endif
# Estimating the size of the output based on poincare()
top = length (X) - (embdim - comp) * delay - 1;
bottom = (comp-1) * delay + 1;
if (direction == false) # from below
output_size = sum ((X(bottom:top) < where) & (X((bottom:top)+1) >= where));
else # from above
output_size = sum ((X(bottom:top) > where) & (X((bottom:top)+1) <= where));
endif
# Correct X to always have more rows than columns
trnspsd = false;
if (rows (X) < columns (X))
X = X.';
trnspsd = true;
endif
output = __poincare__ (X, embdim, delay, comp, where, direction, ...
output_size);
if (trnspsd)
output = output.';
endif
endfunction
%!shared in
%! idx = (1:1500).';
%! in = (5 + mod (idx, 165) ./15) .* sin (idx.* 2 * pi /32);
%!fail("poincare(ones(1,100), 'a',2)");
%!test
%% res was generated using TISEAN poincare
%! res = [-8.732896 31.99873;-10.86617 31.99921;-12.99946 31.99945;-15.13276 31.9996;-6.266347 32.00327;-8.399575 31.99862;-10.53284 31.99915;-12.66613 31.99942;-14.79943 31.99958;-5.933037 32.00351;-8.066255 31.9985;-10.19952 31.99909;-12.3328 31.99939;-14.4661 31.99956;-5.599729 32.00378;-7.732935 31.99835;-9.866194 31.99903;-11.99948 31.99936;-14.13278 31.99954;-5.266423 32.00409;-7.399617 31.99819;-9.53287 31.99895;-11.66615 31.99932;-13.79945 31.99952;-15.8539 32.00443;-7.066301 31.998;-9.199547 31.99887;-11.33282 31.99927;-13.46612 31.99949;-15.5982 32.00483;-6.732986 31.99777;-8.866225 31.99878;-10.9995 31.99923;-13.13279 31.99947;-15.26609 31.99961;-6.399672 32.00318;-8.532903 31.99867;-10.66617 31.99917;-12.79946 31.99944;-14.93276 31.99959;-6.066361 32.00341;-8.199583 31.99855;-10.33285 31.99912;-12.46614 31.9994;-14.59944 31.99957];
%! out = poincare (in, 'd', 8);
%! assert (out, res, -1e-6);
%!test
%! out1 = poincare (in, 'd', 8, 'a', 5, 'm', 4, 'q',2);
%! out2 = poincare (in.', 'd', 8, 'a', 5, 'm', 4, 'q',2);
%! assert (out1.', out2);
%!test
%% res is generated using TISEAN poincare
%! res = [-5.563829; -5.461439; -5.390335; -1.853666; -6.040217; -5.754689; -5.584079; -5.474914; -5.400042; -1.78616; -5.78973; -5.605601; -5.489201; -5.410223; -1.715693; -5.828184; -5.628599; -5.504373; -5.420839; -5.360583; -5.870574; -5.653412; -5.520517; -5.432019; -5.368852; -5.916176; -5.680265; -5.537728; -5.443809; -5.377509; -5.96597; -5.709419; -5.556116; -5.45626; -5.386582; -1.879881; -6.018371; -5.741184; -5.575807; -5.469431; -5.396102; -1.813507; -5.77533; -5.596867; -5.483384; -5.406102; -1.744247];
%! out = poincare (in, 'd', 8, 'a', 5, 'm', 4, 'q',2);
%! assert (out(:,3), res, -1e-6);
tisean-0.2.3/inst/PaxHeaders.27446/pca.m 0000644 0000000 0000000 00000000131 12563465360 014451 x ustar 00 30 mtime=1439591152.324480842
30 atime=1439591152.324480842
29 ctime=1439591152.98447253
tisean-0.2.3/inst/pca.m 0000644 0001750 0001750 00000015242 12563465360 015527 0 ustar 00josiah josiah 0000000 0000000 ## Copyright (C) 1996-2015 Piotr Held
##
## This file is part of Octave.
##
## Octave is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public
## License as published by the Free Software Foundation;
## either version 3 of the License, or (at your option) any
## later version.
##
## Octave is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied
## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
## PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public
## License along with Octave; see the file COPYING. If not,
## see .
## -*- texinfo -*-
## @deftypefn{Function File} {@var{eigval} =} pca (@var{S})
## @deftypefnx{Function File} {[@var{eigval}, @var{eigvec}] =} pca (@var{S})
## @deftypefnx{Function File} {[@var{eigval}, @var{eigvec}, @var{ts}] =} pca (@var{S})
## @deftypefnx{Function File} {[@dots{}] =} pca (@var{S}, @var{paramName}, @var{paramValue}, @dots{})
##
## Performs a global principal component analysis (PCA). It gives the
## eigenvalues of the covariance matrix and depending on the flag @var{w}
## settings the eigenvectors, projections of the input time series.
##
## @strong{Input}
##
## @table @var
## @item S
## This function always assumes that each time series is along the longer
## dimension of matrix @var{S}. It also assumes that every dimension
## (counting along the shorter dimension) of @var{S} is considered a
## component of the time series.
## @end table
##
## @strong{Parameters}
##
## @table @var
## @item m
## Defines embedding dimension. Since all of the data in @var{S} is analysed
## there is no need for setting the number of columns to be read (as is the
## case in TISEAN 'pca') [default = 1].
## @item d
## Delay must be scalar integer [default = 1].
## @item q
## Determines the properties of @var{TS}. When parameter @var{w} is set then
## @var{q} determines the projection dimension. Otherwise it determines the
## number of components written to output [default = full dimension/all
## components].
## @end table
##
## @strong {Switch}
##
## @table @var
## @item w
## If @var{w} is set then @var{TS} is a projection of the time series onto the
## first @var{q} eigenvectors (global noise reduction).
## If @var{w} is not set then @var{TS} is a transformation of the time
## series onto the eigenvector basis. The number of projection
## dimension/components printed is determined by parameter @var{q}.
## @end table
##
## @strong{Output}
##
## @table @var
## @item eigval
## The calculated eigenvalues.
## @item eigvec
## The eigenvectors. The vectors are alligned with the longer dimension of
## @var{S}.
## @item ts
## If @var{w} is set then this variable holds the projected time series
## onto the first @var{q} eigenvectors. If @var{w} is not set then @var{TS} is
## the transformed time series onto the eigenvector basis (number of
## components == parameter @var{q}).
## @end table
##
## @strong{Algorithms}
##
## The algorithms for this functions have been taken from the TISEAN package.
## @end deftypefn
## Author: Piotr Held .
## This function is based on pca of TISEAN 3.0.1
## https://github.com/heggus/Tisean"
function [eigval, eigvec, TS] = pca (S, varargin)
if (nargin < 1)
print_usage;
endif
if ((ismatrix (S) == false) || (isreal(S) == false))
error ('Octave:invalid-input-arg', "S must be a realmatrix");
endif
# Define default values for pca variables
dim = 2;
dimset = 0;
emb = 1;
delay = 1;
ldim = 2;
projection_set = 0;
#### Parse the input
p = inputParser ();
p.FunctionName = "pca";
isPositiveIntScalar = @(x) isreal(x) && isscalar (x) && ...
(x > 0) && (x-round(x) == 0);
p.addParamValue ("m", emb, isPositiveIntScalar);
p.addParamValue ("d", delay, isPositiveIntScalar);
p.addParamValue ("q", ldim, isPositiveIntScalar);
p.addSwitch ("w");
p.parse (varargin{:});
# Assign inputs
emb = p.Results.m;
dimset = !ismember ('m',p.UsingDefaults);
delay = p.Results.d;
ldim = p.Results.q;
projection_set = !ismember ('q',p.UsingDefaults);
w = p.Results.w;
if (w && (nargout < 3))
error ('Octave:invalid-fun-call', "Do not set flag 'w' when less than 3 output values");
endif;
# Correct S to always have more rows than columns
trnspsd = false;
if (rows (S) < columns (S))
S = S.';
trnspsd = true;
endif
if (columns (S) != dim)
dim = columns (S);
dimset = 1;
endif
# Compute output for various inputs.
switch (nargout)
case { 0, 1, 2 }
w = 1;
[eigval, eigvec] = __pca__ (S, dim, emb, delay, ldim, projection_set, w);
case 3
# The value of 'w' is set to correspond to the 'W' flag from TISEAN in determining
# the value of TS. Eigval and eigvec are equivalent to the lower values of 'W' from TISEAN
# that is '-W0' and '-W1'.
if (w)
w = 3;
else
w = 2;
endif;
[eigval, eigvec, TS] = __pca__ (S, dim, emb, delay, ldim, projection_set, w);
# Fix output to allign with input
if (trnspsd)
TS = TS.';
endif;
otherwise
error ('Octave:invalid-fun-call', "Too many output variables");
endswitch
# Fix the output to allign with the input
if (trnspsd)
eigval = eigval.';
eigvec = eigvec.';
endif
endfunction
%!test
%! a = (1:300).';
%! b = [zeros(100,1); ones(100,1); zeros(100,1)];
%! res = [0, 7.499917e+03; 1, 2.222222e-01];
%! assert (pca ([a,b]), res, -1e-6);
%!test
%! a = (1:300).';
%! b = sin (a / (2*pi));
%! res = [-1.000000e+00, -1.105892e-04; 1.105892e-04, -1.000000e+00];
%! [eval, evec] = pca ([a,b]);
%! assert (evec, res, -1e-6);
%!test
%! a = (1:10).';
%! b = [0; 0; 0; 0; 1; 1; 1; 0; 0; 0];
%! res = [-9.998261e-01, 1.864698e-02; -1.999652e+00, 3.729397e-02; -2.999478e+00, 5.594095e-02; -3.999305e+00, 7.458794e-02; -5.017778e+00, -9.065912e-01; -6.017604e+00, -8.879442e-01; -7.017430e+00, -8.692972e-01; -7.998609e+00, 1.491759e-01; -8.998435e+00, 1.678229e-01; -9.998261e+00, 1.864698e-01];
%! [eval, evec, ts] = pca ([a,b]);
%! assert (ts, res, -1e-6);
%!test
%! a = (1:10).';
%! b = [0; 0; 0; 1; 1; 0; 0; 1; 0; 0];
%! res = [1.000000e+00, -5.551115e-17; 2.000000e+00, -5.551115e-17; 3.000000e+00, -5.551115e-17; 4.000000e+00, 1.000000e+00; 5.000000e+00, 1.000000e+00; 6.000000e+00, -5.551115e-17; 7.000000e+00, -1.110223e-16; 8.000000e+00, 1.000000e+00; 9.000000e+00, -5.551115e-17; 1.000000e+01, -1.110223e-16];
%! [eval, evec, ts] = pca ([a,b], 'w');
%! assert (ts, res, -1e-6);
%!xtest (pca (rand(2,10)));
tisean-0.2.3/inst/PaxHeaders.27446/upo.m 0000644 0000000 0000000 00000000131 12563465360 014511 x ustar 00 30 mtime=1439591152.328480792
30 atime=1439591152.328480792
29 ctime=1439591152.98447253
tisean-0.2.3/inst/upo.m 0000644 0001750 0001750 00000017050 12563465360 015566 0 ustar 00josiah josiah 0000000 0000000 ## Copyright (C) 1996-2015 Piotr Held
##
## This file is part of Octave.
##
## Octave is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public
## License as published by the Free Software Foundation;
## either version 3 of the License, or (at your option) any
## later version.
##
## Octave is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied
## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
## PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public
## License along with Octave; see the file COPYING. If not,
## see .
## -*- texinfo -*-
## @deftypefn{Function File} {[@var{olens}, @var{orbit_data}, @var{acc}, @var{stab}] =} upo (@var{X}, @var{m})
## @deftypefnx{Function File} {@dots{} =} upo (@var{X}, @var{m}, @var{paramName}, @var{paramValue}, @dots{})
##
## Locates unstable periodic points.
##
## Note: This function provides a wrapper for the original upo from TISEAN. The
## documentation to TISEAN states that upo has not been tested thoroughly
## and therefore might contain errors. Since this function only provides
## a wrapper for the TISEAN upo any such errors will be inherited. For
## more information consult the TISEAN documentation:
## http://www.mpipks-dresden.mpg.de/~tisean/Tisean_3.0.1/docs/docs_f/upo.html
##
## @strong{Inputs}
##
## @table @var
## @item X
## Must be realvector. If it is a row vector then the output will
## be row vectors as well. Maximum length is 1e6. This constraint existed in
## the TISEAN program and therefore it is inherited. This should not
## be a problem as this program takes 9 seconds for a 10000 element long
## noisy henon series.
## @item m
## Embedding dimension. Must be scalar positive integer.
## @end table
##
## @strong{Parameters}
##
## Either @var{r} or @var{v} must be set and at least one must be
## different from zero.
## @table @var
## @item r
## Absolute kernel bandwidth. Must be a scalar.
## @item v
## Same as fraction of standard deviation.
## @item mtp
## Minimum separation of trial points
## [default = value of 'r' OR std(data) * value of 'v'].
## @item mdo
## Minimum separation of distinct orbits
## [default = value of 'r' OR std(data) * value of 'v'].
## @item s
## Initial separation for stability
## [default = value of 'r' OR std(data) * value of 'v'].
## @item a
## Maximum error of orbit to be plotted [default = all plotted].
## @item p
## Period of orbit [default = 1].
## @item n
## Number of trials [default = numel (@var{X})].
## @end table
##
## @strong{Outputs}
##
## @table @var
## @item olens
## A vector that contains the period lengths (sizes) for each orbit.
## @item orbit_data
## A vector that contains all of the orbit data. To find data for the
## n-the orbit you need to:
## @example
##
## nth_orbit_data = orbit_data(sum(olens(1:n-1)).+(1:olens(n)));
##
## @end example
## @item acc
## A vector that contains the accuracy of each orbit.
## @item stab
## A vector that contains the stability of each orbit.
## @end table
## Note that
##
## @code{length (olens) == length (acc) == length (stab) #== number of orbits}.
##
## @seealso{demo upo, upoembed}
##
## @strong{Algorithms}
##
## The algorithms for this functions have been taken from the TISEAN package.
## @end deftypefn
## Author: Piotr Held .
## This function is based on upo of TISEAN 3.0.1
## https://github.com/heggus/Tisean"
function [olens, orbit_data, acc, stab] = upo (X,m,varargin)
# Initial input validation
if (nargin < 2)
print_usage;
endif
if ((isvector (X) == false) || (isreal(X) == false))
error ('Octave:invalid-input-arg', "X must be a realvector");
endif
# Checking if the input is too long for
# the underlying fortran program
if (length (X) > 1e6)
error ('Octave:invalid-input-arg', ...
"X cannot contain more than 1e6 elements");
endif
isPositiveIntScalar = @(x) isreal(x) && isscalar (x) && ...
(x > 0) && (x-round(x) == 0);
if (isPositiveIntScalar(m) == false)
error ('Octave:invalid-input-arg', ["m must be a scalar positive ",...
"integer value"]);
endif
# Load defaults
eps = 0;
frac = 0;
teq = -1;
tdis = -1;
h = -1;
tacc = -1;
iper = 1;
icen = length (X);
#### Parse the input
p = inputParser ();
p.FunctionName = "upo";
isNumericScalar = @(x) isreal(x) && isscalar (x);
p.addParamValue ("r", eps, isNumericScalar);
p.addParamValue ("v", frac, isNumericScalar);
p.addParamValue ("mtp", teq, isNumericScalar);
p.addParamValue ("mdo", tdis, isNumericScalar);
p.addParamValue ("s", h, isNumericScalar);
p.addParamValue ("a", tacc, isNumericScalar);
p.addParamValue ("p", iper, isPositiveIntScalar);
p.addParamValue ("n", icen, isPositiveIntScalar);
p.parse (varargin{:});
# Assign inputs
eps = p.Results.r;
frac = p.Results.v;
teq = p.Results.mtp;
tdis = p.Results.mdo;
h = p.Results.s;
tacc = p.Results.a;
iper = p.Results.p;
icen = p.Results.n;
# Input validation
if (ismember ('r',p.UsingDefaults) && ismember ('v', p.UsingDefaults))
error ('Octave:invalid-input-arg', "Either parameter 'r' or 'v' \
must be set");
endif
if ((eps == 0) && (frac == 0))
error ('Octave:invalid-input-arg', "Either parameter 'r' or 'v' \
must be different from zero");
endif
# Correct X to always have more rows than columns
trnspsd = false;
if (rows (X) < columns (X))
X = X.';
trnspsd = true;
endif
[olens, orbit_data, acc, stab] = ...
__upo__ (X, m, eps, frac, teq, tdis, h, tacc, iper, icen);
orbit_no = olens(1);
data_no = orbit_data(1);
olens(1) = [];
orbit_data(1) = [];
acc(1) = [];
stab(1) = [];
olens = resize (olens,[orbit_no,1]);
orbit_data = resize (orbit_data,[data_no,1]);
acc = resize (acc,[orbit_no,1]);
stab = resize (stab,[orbit_no,1]);
if (trnspsd)
olens = olens.';
orbit_data = orbit_data.';
acc = acc.';
stab = stab.';
endif
endfunction
%!demo
%! hen = henon (1000);
%! # The following line is equvalent to 'addnoise -v0.1 hen' from TISEAN
%! hen = hen + std (hen) * 0.1 .* (-6 + sum (rand ([size(hen), 12]), 3));
%! hendel = delay (hen(:,1));
%! [olens, odata] = upo(hen(:,1), 2, 'p',6,'v',0.1, 'n', 100);
%! up = upoembed (olens, odata, 1);
%! plot (hendel(:,1), hendel(:,2), 'r.', 'markersize',2, ...
%! up{4}(:,1), up{4}(:,2),'gx','markersize',20,'linewidth',1, ...
%! up{3}(:,1), up{3}(:,2),'b+','markersize',20,'linewidth',1, ...
%! up{2}(:,1), up{2}(:,2),'ms','markersize',20,'linewidth',1, ...
%! up{1}(:,1), up{1}(:,2),'ws','markerfacecolor', 'c', 'markersize',20);
%! legend ('Noisy Henon', 'Fixed Point','Period 2', 'Period 6', 'Period 6');
%! axis tight
%!###############################################################
%!fail("upo((1:10),2,'r',0,'v',0)");
%!fail("upo((1:10),2)");
%!fail("upo(1:10)");
%!fail("upo(zeros(1e6+1,1),2)");
%!test
%! hen = henon (1000);
%! res_lens = [6;6;2;1];
%! res_odata = [0.476636350; 0.790967643; 0.223789170; 1.14927197; -0.771639466; 0.450597405; 0.310742706; 1.01709056; -0.403215200; 1.06800783; -0.734883010; 0.569545567; 0.975725055; -0.495307118; 0.640587449];
%! res_acc = [5.09480287E-07 ; 7.82842960E-07; 5.84763768E-07; 5.19621267E-07];
%! res_stab = [12.6414680; 10.4631128; 2.43191552; 1.63386893];
%! [l,d,a,s] = upo(hen(:,1),2,'p',6,'v',0.1,'n',100);
%! assert ({l,d},{res_lens,res_odata},-1e-5);
tisean-0.2.3/inst/PaxHeaders.27446/d2.m 0000644 0000000 0000000 00000000131 12563465360 014213 x ustar 00 30 mtime=1439591152.316480943
30 atime=1439591152.316480943
29 ctime=1439591152.98447253
tisean-0.2.3/inst/d2.m 0000644 0001750 0001750 00000031005 12563465360 015264 0 ustar 00josiah josiah 0000000 0000000 ## Copyright (C) 1996-2015 Piotr Held
##
## This file is part of Octave.
##
## Octave is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public
## License as published by the Free Software Foundation;
## either version 3 of the License, or (at your option) any
## later version.
##
## Octave is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied
## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
## PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public
## License along with Octave; see the file COPYING. If not,
## see .
## -*- texinfo -*-
## @deftypefn{Function File} {[@var{values}, @var{pars}] =} d2 (@var{S})
## @deftypefnx{Function File} {[@var{values}, @var{pars}] =} d2 (@var{S}, @var{paramName}, @var{paramValue}, @dots{})
##
## This program estimates the correlation sum, the correlation dimension and
## the correlation entropy of a given, possibly multivariate, data set. It uses
## the box assisted search algorithm and is quite fast as long as one is not
## interested in large length scales. All length scales are computed
## simultaneously and the current center and epsilon are written every 2 min
## (real time, not cpu time) or every set number of center value increases.
## It is possible to set a maximum number of pairs. If this number is
## reached for a given length scale, the length scale will no longer be treated
## for the rest of the estimate.
##
## @strong{Input}
##
## @table @var
## @item S
## This function always assumes that each time series is along the longer
## dimension of matrix @var{S}. It also assumes that every dimension
## (counting along the shorter dimension) of @var{S} is considered a
## component of the time series.
## @end table
##
## @strong{Parameters}
##
## @table @var
## @item m
## The maximum embedding dimension [default = 10].
## @item d
## The delay used [default = 1].
## @item t
## Theiler window [default = 0].
## @item rlow
## Minimum length scale [default = 1e-3].
## @item rhigh
## Maximum length scale [default = 1].
## @item eps_no
## Number of length scale values [default = 100].
## @item n
## Maximum number of pairs to be used (value 0 means all possible pairs)
## [default = 1000].
## @item p
## This parameter determines after how many iterations (center points)
## should the program pause and write out how many center points have been
## treated so far and the current epsilon. If @var{plot_corr} or
## @var{plot_slopes} or @var{plot_entrop} is set then during the pause a plot
## of the current state of @var{c2}, @var{d2} or @var{h2} (respectively)
## is produced. Regardless of the value of this parameter the program will
## pause every two minutes [default = only pause every 2 minutes].
## @end table
##
## @strong{Switches}
##
## @table @var
## @item normalized
## When this switch is set the program uses data normalized to [0,1] for all
## components.
## @item plot_corr
## If this switch is set then whenever the execution is paused (the frequency
## can be set with parameter @var{p}) the most recent correlation sums are
## plotted. The color used for them is blue.
## @item plot_slopes
## Same as @var{plot_corr} except the plotted values are the local slopes.
## They are plotted in red.
## @item plot_entrop
## Same as @var{plot_corr} except the correlation entropies are plotted.
## They are plotted in green.
## @end table
##
## @strong{Output}
##
## @table @var
## @item values
## This is a struct array that contains the following fields:
## @itemize @bullet
## @item
## dim - the dimension of the data
## @item
## c2 - the first column is the epsilon and the second the correlation sums for
## a particular embedding dimension
## @item
## d2 - the first column is the epsilon and the second the local slopes of
## the logarithm of the corrlation sum
## @item
## h2 - the first column is the epsilon and the second the correlation
## entropies
## @end itemize
## @item pars
## This is a struct. It contains the following fields:
## @itemize @bullet
## @item
## treated - the number of center points treated
## @item
## eps - the maximum epsilon used
## @end itemize
## @end table
##
## @seealso{demo d2, av_d2, c2t, c2g}
##
## @strong{Algorithms}
##
## The algorithms for this functions have been taken from the TISEAN package.
## @end deftypefn
## Author: Piotr Held .
## This function is based on d2 of TISEAN 3.0.1
## https://github.com/heggus/Tisean"
function [values, pars] = d2 (S, varargin)
if (nargin < 1 || nargout > 2)
print_usage;
endif
if ((ismatrix (S) == false) || (isreal(S) == false) || ...
(isreal(S) == false))
error ('Octave:invalid-input-arg', "S must be a realmatrix");
endif
# Default values
embed = 10;
delay = 1;
mindist = 0;
epsmin = 1e-3;
epsmax = 1.0;
howoften = 100;
maxfound = 1000;
iterator_pause = length (S);
#### Parse the input
p = inputParser ();
p.FunctionName = "d2";
isPositiveIntScalar = @(x) isreal(x) && isscalar (x) && ...
(x > 0) && (x-round(x) == 0);
isNonNegativeIntScalar = @(x) isPositiveIntScalar (x) || (x == 0);
isPositiveScalar = @(x) isreal(x) && isscalar (x) && (x > 0);
p.addParamValue ("m", embed, isPositiveIntScalar);
p.addParamValue ("d", delay, isPositiveIntScalar);
p.addParamValue ("t", mindist, isNonNegativeIntScalar);
p.addParamValue ("rlow", epsmin, isPositiveScalar);
p.addParamValue ("rhigh", epsmax, isPositiveScalar);
p.addParamValue ("eps_no", howoften, isPositiveIntScalar);
p.addParamValue ("n", maxfound, isNonNegativeIntScalar);
p.addParamValue ("p", iterator_pause, isPositiveIntScalar);
p.addSwitch ("normalized");
p.addSwitch ("plot_corr");
p.addSwitch ("plot_slopes");
p.addSwitch ("plot_entrop");
p.parse (varargin{:});
# Assign inputs
embed = p.Results.m;
delay = p.Results.d;
mindist = p.Results.t;
epsmin = p.Results.rlow;
eps_min_set = !ismember ("rlow", p.UsingDefaults);
epsmax = p.Results.rhigh;
eps_max_set = !ismember ("rhigh", p.UsingDefaults);
howoften = p.Results.eps_no;
maxfound = p.Results.n;
rescale_set = p.Results.normalized;
iterator_pause = p.Results.p;
plot_corr = p.Results.plot_corr;
plot_slopes = p.Results.plot_slopes;
plot_entrop = p.Results.plot_entrop;
# Input validation
# Check if the delay and embedding dimensions are too large
if ((length (S)-(embed-1)*delay) <= 0)
error ("Octave:invalid-input-arg","Embedding dimension and delay are too \
large, the delay vector would be longer than the whole series.");
endif
# Check if rlow is smaller than rhigh
if (epsmin >= epsmax)
warning ("Octave:tisean", "'rlow' is greater or equal to 'rhigh'");
endif
# Correct S to always have more rows than columns
trnspsd = false;
if (rows (S) < columns (S))
S = S.';
trnspsd = true;
endif
[values, vars] = __d2__ (S, embed, delay, mindist, epsmin, eps_min_set,
epsmax, eps_max_set, howoften, maxfound,
rescale_set,iterator_pause);
# Pause calculations and if flags are set, plot current state of the output.
calc_paused = false;
while (isfield (vars, "counter") ...
&& vars.counter < (length (S) - (embed-1)*delay))
calc_paused = true;
printf ("\n");
treated = vars.treated
epsilon = vars.eps
fflush (stdout);
figure_no = 1;
if (plot_corr)
h = figure (figure_no);
figure_no += 1;
do_plot_corr = @(x) loglog (x{1}(:,1),x{1}(:,2),'b');
clf (h)
hold on
arrayfun (do_plot_corr, {values.c2});
hold off
xlabel ("Epsilon")
ylabel ("Correlation sums")
drawnow ()
endif
if (plot_slopes)
h = figure (figure_no);
figure_no += 1;
do_plot_slope = @(x) semilogx (x{1}(:,1),x{1}(:,2),'r');
clf (h)
hold on
arrayfun (do_plot_slope, {values.d2});
hold off
xlabel ("Epsilon")
ylabel ("Local slopes")
drawnow ()
endif
if (plot_entrop)
h =figure (figure_no);
figure_no += 1;
do_plot_entrop = @(x) semilogx (x{1}(:,1),x{1}(:,2),'g');
clf (h)
hold on
arrayfun (do_plot_entrop, {values.h2});
hold off
xlabel ("Epsilon")
ylabel ("Correlation entropies");
drawnow ()
endif
# Continue on with computation
[values, vars] = __d2__ (S, embed, delay, mindist, vars.EPSMIN,
eps_min_set, vars.EPSMAX, eps_max_set, howoften,
maxfound, rescale_set, iterator_pause,
vars.counter, vars.found, vars.norm, vars.boxc1,
vars.box, vars.list, vars.listc1, vars.imin,
vars.EPSMAX1);
endwhile
if (calc_paused)
printf ("\n");
fflush (stdout);
endif
pars = vars;
endfunction
%!demo
%! vals = d2 (henon (1000), 'd', 1, 'm', 5, 't',50);
%!
%! subplot (2,3,1)
%! do_plot_corr = @(x) loglog (x{1}(:,1),x{1}(:,2),'b');
%! hold on
%! arrayfun (do_plot_corr, {vals.c2});
%! hold off
%! axis tight
%! xlabel ("Epsilon")
%! ylabel ("Correlation sums")
%! title ("c2");
%!
%! subplot (2,3,4)
%! do_plot_entrop = @(x) semilogx (x{1}(:,1),x{1}(:,2),'g');
%! hold on
%! arrayfun (do_plot_entrop, {vals.h2});
%! hold off
%! axis tight
%! xlabel ("Epsilon")
%! ylabel ("Correlation entropies");
%! title ("h2")
%!
%! subplot (2,3,[2 3 5 6])
%! do_plot_slope = @(x) semilogx (x{1}(:,1),x{1}(:,2),'r');
%! hold on
%! arrayfun (do_plot_slope, {vals.d2});
%! hold off
%! axis tight
%! xlabel ("Epsilon")
%! ylabel ("Local slopes")
%! title ("d2");
%!###############################################################
%!shared res, pars
%! [res, pars] = d2 (henon (100)(:,1),'m',2,'eps_no',20,'t',50);
%!test
%! res_d2_stat = [98 1.777433e+00];
%! assert ([pars.treated pars.eps], res_d2_stat, -1e-6);
%% test d2 field of output
%!test
%! res_d2_d2 = [1.777433 0.30648;1.235659 0.5606802;0.859021 0.7008824;0.5971852 0.8064865;0.4151589 0.9044852;0.2886154 0.9689651;0.2006434 0.8540874;0.1394858 0.8112826;0.09696954 0.8935407;0.06741253 0.9143867;0.0468647 0.856615;0.03258 0.8627251;0.02264938 1.503286;0.01574569 1.447036;0.01094629 0.7216412;0.007609782 0.6137634;0.005290265 1.29276;0.003677754 1.405042;1.777433 0.645521;1.235659 1.002253;0.859021 1.056272;0.5971852 1.026064;0.4151589 1.402018;0.2886154 1.565816;0.2006434 0.6950658;0.1394858 1.238292;0.09696954 0.9580286;0.06741253 1.75781;0.0468647 1.043798;0.03258 2.628165;0.02264938 1.405042;0.01574569 1.115245];
%! assert (cell2mat({res.d2}.'), res_d2_d2, -1e-6);
%% test h2 field of output
%!test
%! res_d2_h2 = [2.556748 -0;1.777433 0.1114257;1.235659 0.31527;0.859021 0.5700871;0.5971852 0.8632982;0.4151589 1.192138;0.2886154 1.544421;0.2006434 1.854938;0.1394858 2.149893;0.09696954 2.474754;0.06741253 2.807194;0.0468647 3.11863;0.03258 3.432288;0.02264938 3.978832;0.01574569 4.504925;0.01094629 4.767289;0.007609782 4.990433;0.005290265 5.460436;0.003677754 5.971262;2.556748 0;1.777433 0.1232638;1.235659 0.2838046;0.859021 0.4130123;0.5971852 0.4928431;0.4151589 0.6737291;0.2886154 0.890724;0.2006434 0.8329091;0.1394858 0.9881553;0.09696954 1.011601;0.06741253 1.318241;0.0468647 1.386294;0.03258 2.028148;0.02264938 1.99243;0.01574569 1.871802];
%! assert (cell2mat({res.h2}.'), res_d2_h2, -1e-6);
%% test c2 field of output
%!test
%! res_d2_c2 = [2.556748 1;1.777433 0.8945578;1.235659 0.7295918;0.859021 0.5654762;0.5971852 0.4217687;0.4151589 0.3035714;0.2886154 0.2134354;0.2006434 0.1564626;0.1394858 0.1164966;0.09696954 0.08418367;0.06741253 0.06037415;0.0468647 0.04421769;0.03258 0.03231293;0.02264938 0.01870748;0.01574569 0.01105442;0.01094629 0.008503401;0.007609782 0.006802721;0.005290265 0.004251701;0.003677754 0.00255102;0.002556748 0;2.556748 1;1.777433 0.7908163;1.235659 0.5493197;0.859021 0.3741497;0.5971852 0.2576531;0.4151589 0.1547619;0.2886154 0.08758503;0.2006434 0.06802721;0.1394858 0.04336735;0.09696954 0.03061224;0.06741253 0.01615646;0.0468647 0.01105442;0.03258 0.004251701;0.02264938 0.00255102;0.01574569 0.00170068;0.01094629 0;0.007609782 0;0.005290265 0;0.003677754 0;0.002556748 0];
%! assert (cell2mat({res.c2}.'), res_d2_c2, -1e-6);
%% Test input validation
%!error d2 (1:5);
%% Promote warnings to error to not execute program
%!error warning("error", "Octave:tisean"); ...
%! d2 (henon (1000), 'rlow', 4, 'rhigh', 1);
tisean-0.2.3/inst/PaxHeaders.27446/c1.m 0000644 0000000 0000000 00000000131 12563465360 014211 x ustar 00 30 mtime=1439591152.316480943
30 atime=1439591152.316480943
29 ctime=1439591152.98447253
tisean-0.2.3/inst/c1.m 0000644 0001750 0001750 00000022203 12563465360 015262 0 ustar 00josiah josiah 0000000 0000000 ## Copyright (C) 1996-2015 Piotr Held
##
## This file is part of Octave.
##
## Octave is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public
## License as published by the Free Software Foundation;
## either version 3 of the License, or (at your option) any
## later version.
##
## Octave is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied
## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
## PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public
## License along with Octave; see the file COPYING. If not,
## see .
## -*- texinfo -*-
## @deftypefn{Function File} {@var{output} =} c1 (@var{S})
## @deftypefnx{Function File} {@var{output} =} c1 (@var{S}, @var{paramName}, @var{paramValue}, @dots{})
##
## Computers curves for the fixed mass computation of information dimension
## (mentioned in TISEAN 3.0.1 documentation).
##
## A logarithmic range of masses between 1/N and 1 is realised by varying the
## neighbour order k as well as the subsequence length n. For a given mass
## k/n, n is chosen as small is possible as long as k is not smaller than the
## value specified by parameter @var{k} .
##
## You will probably use the auxiliary functions c2d or c2t to process the
## output further. The formula used for the Gaussian kernel correlation sum
## does not apply to the information dimension.
##
## @strong{Input}
##
## @table @var
## @item S
## This function always assumes that each time series is along the longer
## dimension of matrix @var{S}. It also assumes that every dimension
## (counting along the shorter dimension) of @var{S} is considered a
## component of the time series.
## @end table
##
## @strong{Parameters}
##
## @table @var
## @item mindim
## The minimum embedding dimension [default = 1].
## @item maxdim
## The maximum embedding dimension [default = 10].
## @item d
## The delay used [default = 1].
## @item t
## Minimum time separation [default = 0].
## @item n
## The number of reference points. That number of points are selected at
## random from all time indices [default = 100].
## @item res
## Resolution, values per octave [default = 2].
## @item i
## Seed for the random numbers [use default seed].
## @item k
## Maximum number of neighbors [default = 100].
## @end table
##
## @strong{Switch}
##
## @table @var
## @item verbose
## Display information about current mass during execution.
## @end table
##
## @strong{Output}
##
## The output is a @var{maxdim} - @var{mindim} + 1 x 1 struct array with the
## following fields:
## @table @var
## @item dim
## The embedding dimension of the struct.
## @item c1
## A matrix with two collumns that contain the following data:
## @enumerate
## @item
## radius
## @item
## 'mass'
## @end enumerate
## @end table
##
## @seealso{demo c1, c2d, c2t}
##
## @strong{Algorithms}
##
## The algorithms for this functions have been taken from the TISEAN package.
## @end deftypefn
## Author: Piotr Held .
## This function is based on c1 of TISEAN 3.0.1
## https://github.com/heggus/Tisean"
function output = c1 (S, varargin)
if (nargin < 1)
print_usage;
endif
if ((ismatrix (S) == false) || (isreal(S) == false) || ...
(isreal(S) == false))
error ('Octave:invalid-input-arg', "S must be a realmatrix");
endif
# Default values
mindim = 1;
maxdim = 10;
delay = 1;
tmin = 0;
cmin = 100;
resolution = 2;
seed = 0;
kmax = 100;
#### Parse the input
p = inputParser ();
p.FunctionName = "c1";
isPositiveIntScalar = @(x) isreal(x) && isscalar (x) && ...
(x > 0) && (x-round(x) == 0);
isNonNegativeIntScalar = @(x) isPositiveIntScalar (x) || (x == 0);
isNonNegativeScalar = @(x) isreal(x) && isscalar (x) && (x >=0);
p.addParamValue ("mindim", mindim, isPositiveIntScalar);
p.addParamValue ("maxdim", maxdim, isPositiveIntScalar);
p.addParamValue ("d", delay, isPositiveIntScalar);
p.addParamValue ("t", tmin, isNonNegativeIntScalar);
p.addParamValue ("n", cmin, isPositiveIntScalar);
p.addParamValue ("res", resolution, isPositiveIntScalar);
p.addParamValue ("i", seed, isNonNegativeScalar);
p.addParamValue ("k", kmax, isPositiveIntScalar);
p.addSwitch ("verbose");
p.parse (varargin{:});
# Assign input
mindim = p.Results.mindim;
maxdim = p.Results.maxdim;
delay = p.Results.d;
tmin = p.Results.t;
cmin = p.Results.n;
resolution = p.Results.res;
seed = p.Results.i;
kmax = p.Results.k;
verbose = p.Results.verbose;
if (mindim > maxdim)
warning ("Octave:tisean", ["Parameter 'mindim' is greater than ", ...
"'maxdim', setting 'mindim' = 'maxdim'"]);
mindim = maxdim;
endif
# Correct S to always have more rows than columns
trnspsd = false;
if (rows (S) < columns (S))
S = S.';
trnspsd = true;
endif
output = __c1__ (S, mindim, maxdim, delay, tmin, cmin, resolution, seed,
kmax, verbose);
endfunction
%!demo
%! res = c1 (henon (5000)(:,1), 'd', 1, 'maxdim', 6, 't',50, 'n', 500);
%! slope = c2d (res, 2);
%!
%! do_plot_c1 = @(x) semilogx (x{1}(:,1),x{1}(:,2),'g');
%! hold on
%! arrayfun (do_plot_c1, {slope.d});
%! plot ([5e-4 1],[1.2 1.2])
%! hold off
%! axis tight
%! ylim ([0 3]);
%! xlabel ("Epsilon")
%! ylabel ("Local slopes");
%! title ("Information dimension")
%!###############################################################
%% testing if it works with default parameters
%!test
%% res_c1 was generated by TISEAN 3.0.1
%! res_c1 = [0.00204866193 0.000562021392;0.00458388403 0.00152773259;0.00732116727 0.00251880521;0.0114847319 0.00351527636;0.0178178754 0.00551304966;0.0229953099 0.00751305372;0.0337692834 0.0115151331;0.0432167873 0.0155181978;0.070036374 0.0225279164;0.0809115991 0.0315354168;0.105735436 0.045548249;0.137048692 0.0635655001;0.198512435 0.0905919373;0.249011219 0.127565667;0.336370319 0.180583045;0.417932093 0.255131334;0.533079803 0.361822665;0.760820627 0.510262668;1.17550445 0.726286411;0.00397582119 0.000562021392;0.00887203496 0.00152773259;0.0129663227 0.00251880521;0.0233632866 0.00451370422;0.0256882776 0.00551304966;0.0377443098 0.00851340499;0.0444159135 0.0115151331;0.0625304207 0.0165190343;0.0792045668 0.0225279164;0.112165064 0.0325363018;0.142160922 0.045548249;0.183529988 0.0645664856;0.247998312 0.0905919373;0.365789354 0.128554597;0.479705334 0.181571603;0.648174882 0.25644654;0.828185916 0.361822665;1.0652355 0.512893081;1.51780188 0.726286411];
%! clear __c1__
%! res = c1 (henon (1000), 'maxdim', 2);
%! res_mat = cell2mat({res.c1}.');
%% row 23 and 25 are excluded because TISEAN data was calculated using floats
%% this program uses doubles
%! good_idx = [1:22,24,26:38];
%! assert (res_mat(good_idx,:), res_c1(good_idx,:),-1e-5);
%% bad_idx are used as the idx of those that were further apart than the rest
%! bad_idx = setdiff (1:length(res_c1),good_idx);
%! assert (res_mat(bad_idx,:), res_c1(bad_idx,:),6e-3);
%% testing if works with other-than-default parameters
%!test
%! res_c1 = [0.0343293324 0.000628733949;0.0685995296 0.00170907611;0.104914345 0.00281779026;0.147767007 0.00393254356;0.187380955 0.00616745465;0.242883027 0.00840486214;0.320845127 0.0117625576;0.424331248 0.0162406135;0.5311203 0.0229629427;0.638983071 0.0319196843;0.77487731 0.0453561395;0.95007056 0.0643920898;1.13252032 0.0912670717;1.33960843 0.129390419;1.51084828 0.182906702;1.65632439 0.259117812;1.78787661 0.365813404;1.93386149 0.518235624;2.13333058 0.731626809;0.0578132086 0.000630145252;0.106152184 0.00171291234;0.163010269 0.0028241151;0.214579925 0.00394137064;0.280628532 0.00618129829;0.353775769 0.00842372701;0.448207438 0.0117889596;0.582583368 0.0162770674;0.693925321 0.0230144858;0.805182397 0.0319913328;0.948441863 0.0454579443;1.12319851 0.0645366237;1.28063464 0.0914719254;1.44319057 0.129558906;1.57120717 0.183243573;1.71812892 0.259117812;1.83539987 0.367163211;1.98069465 0.518235624;2.16835737 0.737046182;0.0653617978 0.000630145252;0.120350979 0.00171291234;0.182360902 0.0028241151;0.22783263 0.00394137064;0.300161123 0.00618129829;0.384833038 0.00842372701;0.497192621 0.0117889596;0.616096795 0.0162770674;0.750326335 0.0230144858;0.908238411 0.0331135131;1.03522205 0.0465802066;1.23226273 0.0656589493;1.37276983 0.0925942659;1.53525198 0.130750626;1.65205204 0.184261546;1.77773058 0.260474414;1.88386154 0.368523091;2.01883292 0.520948827;2.19400668 0.737046182];
%! clear __c1__
%! res = c1 (henon (1000), 'mindim', 8, 'd',2,'i',0.5,'t',50,'n',500);
%% row 1, 2, 22 are excluded because TISEAN data was calculated using floats
%% this program uses doubles
%! good_idx = [3:21,23:57];
%! assert (cell2mat({res.c1}.')(good_idx,:), res_c1(good_idx,:), 1e-5);
%% bad_idx are used as the idx of those that were further apart than the rest
%! bad_idx = setdiff (1:length(res_c1),good_idx);
%! assert (cell2mat({res.c1}.')(bad_idx,:), res_c1(bad_idx,:),-3e-3);
%% Test input validation
%% Promote warnings to error to not execute program
%!error warning("error", "Octave:tisean"); c1 ([1 2 3], 'mindim', 3, 'maxdim', 2);
tisean-0.2.3/inst/PaxHeaders.27446/upoembed.m 0000644 0000000 0000000 00000000131 12563465360 015506 x ustar 00 30 mtime=1439591152.328480792
30 atime=1439591152.328480792
29 ctime=1439591152.98447253
tisean-0.2.3/inst/upoembed.m 0000644 0001750 0001750 00000015104 12563465360 016561 0 ustar 00josiah josiah 0000000 0000000 ## Copyright (C) 1996-2015 Piotr Held
##
## This file is part of Octave.
##
## Octave is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public
## License as published by the Free Software Foundation;
## either version 3 of the License, or (at your option) any
## later version.
##
## Octave is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied
## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
## PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public
## License along with Octave; see the file COPYING. If not,
## see .
## -*- texinfo -*-
## @deftypefn{Function File} {@var{output} =} upoembed (@var{olens},@var{orbit_data}, @var{delay})
## @deftypefnx{Function File} {@var{output} =} upoembed (@var{olens},@var{orbit_data}, @var{delay}, @var{paramName}, @var{paramValue}, @dots{})
##
## Creates delay coordinates for upo output.
##
## @strong{Inputs}
##
## @table @var
## @item olens
## This vector contains the periods that are generated by upo.
## @item orbit_data
## The orbit data that is generated by upo.
## @item delay
## The delay used to get the delay coordinates.
## @end table
##
## @strong{Parameter}
## @table @var
## @item m
## The embedding dimension used [default = 2].
## @item p
## The period of the orbit to be extracted. This may be a vector
## [default = extract all orbit periods].
## @end table
##
## @strong{Output}
##
## A cell that contains the delay vectors for each orbit. The orbits
## are in the same order as they are in @var{olens}. Can be converted to
## matrix using @code{str2mat (output)}.
##
## @seealso{upo}
##
## @strong{Algorithms}
##
## The algorithms for this functions have been taken from the TISEAN package.
## @end deftypefn
## Author: Piotr Held .
## This function is based on upoembed of TISEAN 3.0.1
## https://github.com/heggus/Tisean"
function output = upoembed (olens, orbit_data, delay, varargin)
# Input validation
if (nargin < 3)
print_usage;
endif
isPositiveIntVector = @(x) isreal(x) && isvector (x) && ...
all (x > 0) && all (x-round(x) == 0);
if (isPositiveIntVector (olens) == false)
error ('Octave:invalid-input-arg', "olens must be a realvector");
endif
if ((isvector (orbit_data) == false) || (isreal(orbit_data) == false))
error ('Octave:invalid-input-arg', "orbit_data must be a realvector");
endif
if (sum (olens) != length (orbit_data))
error ('Octave:invalid-input-arg', "The sum of the periods of orbits \
is not equal to the number of orbit data");
endif
isPositiveIntScalar = @(x) isreal(x) && isscalar (x) && ...
(x > 0) && (x-round(x) == 0);
if (isPositiveIntScalar (delay) == false)
error ('Octave:invalid-input-arg', "delay must be a positive \
integer scalar value");
endif
# Assign default values
m = 2;
porbit = 1;
#### Parse the input
p = inputParser ();
p.FunctionName = "upoembed";
isNumericScalar = @(x) isreal(x) && isscalar (x);
p.addParamValue ("m", m, isPositiveIntScalar);
p.addParamValue ("p", porbit, isPositiveIntVector);
p.parse (varargin{:});
# Assing inputs
m = p.Results.m;
porbit = p.Results.p;
## Additional data validation
if (!ismember ('p', p.UsingDefaults) && !(any(ismember (porbit, olens))))
error ('Octave:invalid-input-arg', "parameter p must be one of the \
values of olens");
endif
## Generating indexes of orbits to use
if (!ismember ('p', p.UsingDefaults))
idx = find(ismember(olens, porbit)).';
else
idx = 1:length(olens);
endif
## Create delay vectors
j = (m:-1:1);
delay_vec = @(x) orbit_data(sum(olens(1:idx(x)-1))+ ...
mod(((1:olens(idx(x))+1).').-...
(j-1).*delay -1 +m.*olens(idx(x)),...
olens(idx(x)))+1);
output = arrayfun (delay_vec,(1:length(idx)).','UniformOutput', false);
## Below is unvectorized code (for reference only)
## Does not account for parameter 'p'
## The return is in a single matrix instead of a cell array
# for i=1:length(olens)
# for k=1:olens(i)+1;
# for j=m:-1:1;
# output(sum(olens(1:i-1)+1)+k,m+1-j) = ...
# orbit_data(sum(olens(1:i-1))+mod(k.-(j-1).*delay-1+m*olens(i),olens(i))+1);
# endfor
# endfor
# endfor
endfunction
%!shared olens, odata
%! olens = [6;6;2;1];
%! odata = [0.568860233; 0.320431054; 1.01113260; -0.396884680; 1.06592703; -0.735762954; 0.468448341; 0.791814446; 0.219137505; 1.15340614; -0.777471960; 0.447908580; 0.982830405; -0.487029105; 0.634082019];
%!fail ("upoembed (olens, odata, 1, 'p',3)");
%!xtest ("upoembed (olens, odata, 1, 'p',6)");
%!test
%! "res was generated using 'upoembed -d1' on 'olens' and 'odata' from TISEAN";
%! res = [-0.735762954, 0.568860233; 0.568860233, 0.320431054; 0.320431054, 1.01113260; 1.01113260, -0.396884680; -0.396884680, 1.06592703; 1.06592703, -0.735762954; -0.735762954, 0.568860233; 0.447908580, 0.468448341; 0.468448341, 0.791814446; 0.791814446, 0.219137505; 0.219137505, 1.15340614; 1.15340614, -0.777471960; -0.777471960, 0.447908580; 0.447908580, 0.468448341; -0.487029105, 0.982830405; 0.982830405, -0.487029105; -0.487029105, 0.982830405; 0.634082019, 0.634082019; 0.634082019, 0.634082019];
%! out = upoembed(olens,odata,1,'m',2);
%! out = cell2mat(out);
%! assert (out,res,1e-6);
%!test
%! "res was generated using 'upoembed -p6 -d1' from TISEAN on olens and odata";
%! res = [-0.735762954, 0.568860233; 0.568860233, 0.320431054; 0.320431054, 1.01113260; 1.01113260, -0.396884680; -0.396884680, 1.06592703; 1.06592703, -0.735762954; -0.735762954, 0.568860233; ; ; 0.447908580, 0.468448341; 0.468448341, 0.791814446; 0.791814446, 0.219137505; 0.219137505, 1.15340614; 1.15340614, -0.777471960; -0.777471960, 0.447908580; 0.447908580, 0.468448341];
%! out = upoembed(olens,odata,1,'p',6);
%! out = cell2mat(out);
%! assert (out,res,1e-6);
%!test
%! "TEST FOR WHEN 'P' IS A VECTOR";
%! res = [-0.735762954, 0.568860233; 0.568860233, 0.320431054; 0.320431054, 1.01113260; 1.01113260, -0.396884680; -0.396884680, 1.06592703; 1.06592703, -0.735762954; -0.735762954, 0.568860233; ; ; 0.447908580, 0.468448341; 0.468448341, 0.791814446; 0.791814446, 0.219137505; 0.219137505, 1.15340614; 1.15340614, -0.777471960; -0.777471960, 0.447908580; 0.447908580, 0.468448341; 0.634082019, 0.634082019;0.634082019, 0.634082019];
%! out = upoembed(olens,odata,1,'p',[6 1]);
%! out = cell2mat(out);
%! assert (out,res,1e-6);
tisean-0.2.3/inst/PaxHeaders.27446/ikeda.m 0000644 0000000 0000000 00000000131 12563465360 014763 x ustar 00 30 mtime=1439591152.320480892
30 atime=1439591152.320480892
29 ctime=1439591152.98447253
tisean-0.2.3/inst/ikeda.m 0000644 0001750 0001750 00000010423 12563465360 016035 0 ustar 00josiah josiah 0000000 0000000 ## Copyright (C) 1996-2015 Piotr Held
##
## This file is part of Octave.
##
## Octave is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public
## License as published by the Free Software Foundation;
## either version 3 of the License, or (at your option) any
## later version.
##
## Octave is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied
## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
## PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public
## License along with Octave; see the file COPYING. If not,
## see .
## Author: Piotr Held .
## This function is based on henon of TISEAN 3.0.1 https://github.com/heggus/Tisean"
## -*- texinfo -*-
## @deftypefn{Function File} {@var{output_array} =} ikeda (@var{L}, @dots{})
## @deftypefnx{Function File} {@var{output_array} =} ikeda (@var{L}, @var{paramName}, @var{paramValue}, @dots{})
##
## Generate Ikeda map
##
## @iftex
## @tex
## $$ z_{n+1} = 1 + c * z_{n} * exp (a*i - {{b*i} \over {1+|z_{n}|}})$$
## @end tex
## @end iftex
## @ifnottex
## @example
## b*i
## z(n+1) = 1 + c * z(n) * exp (a*i - ---------)
## 1+|z(n)|
## @end example
## @end ifnottex
##
## @strong{Input}
##
## @table @var
## @item L
## The number of points (x,y), must be integer. Required value.
## @end table
##
## @strong{Parameters}
##
## @table @var
## @item a
## Defines parameter 'a' (default=0.4)
## @item b
## Defines parameter 'b' (default=6.0)
## @item c
## Defines parameter 'c' (default=0.9)
## @item R
## Initial real value of 'z' (default=0.68587)
## @item I
## Initial imaginary value of 'z' (defaul=0.65876)
## @item ntrans
## Defines number of transient points (default=10000),
## must be positive integer scalar
## @end table
##
## @strong{Output}
##
## @var{output} is of length @var{L}. The first columns are the real values
## of the Ikeda Map and the second are the imaginary values of the Ikeda map.
## This is done to be work the same way that 'ikeda' in TISEAN works.
##
## @strong{Usage example}
##
## @code{out = ikeda(1000, "a", 1.25)}
##
## After this command @var{out} will be a 1000x2 matrix with Henon map
## points as rows. It will generate 1000 points.
##
## @strong{Algorithm}
## On basis of TISEAN package ikeda
## @end deftypefn
## Author: Piotr Held .
## This function is based on ikeda of TISEAN 3.0.1
## https://github.com/heggus/Tisean"
function output = ikeda (L, varargin)
% Define default parameters.
a = 0.4;
b = 6.0;
c = 0.9;
x0 = 0.68587;
y0 = 0.65876;
ntransient = 10000;
isPositiveInteger = @(x) isreal(x) && isscalar (x) && (x > 0) && (x-round(x) == 0);
if (nargin < 1)
print_usage();
elseif (isPositiveInteger (L) != true)
error ('Octave:invalid-input-arg', "L must be a positive integer");
endif
#### Parse the input
p = inputParser ();
p.FunctionName = "ikeda";
isRealScalar = @(x) isreal (x) && isscalar (x);
p.addParamValue ("A",a,isRealScalar);
p.addParamValue ("B",b,isRealScalar);
p.addParamValue ("C",c,isRealScalar);
p.addParamValue ("R",x0,isRealScalar);
p.addParamValue ("I",y0,isRealScalar);
isNonNegative = @(x) isreal(x) && isscalar (x) && (x >= 0) && (x-round(x) == 0);
p.addParamValue ("ntrans",ntransient,isNonNegative);
p.parse (varargin{:});
# Asign input
nmax = L;
a = p.Results.A;
b = p.Results.B;
c = p.Results.C;
x0 = p.Results.R;
y0 = p.Results.I;
ntransient = p.Results.ntrans;
% Computing output
output = __ikeda__ (nmax, a, b, c, x0, y0, ntransient);
endfunction
%!test
%! ikd = [0.28571947432035805 0.64340009417266342;0.50841625820931591 -0.39972597757561129;0.87547944209544659 0.56858743316662752;0.70057389172681206 -0.89053147224601548;-1.9710645882970557E-002 -1.0429004993745194E-002;0.99222205960974108 -1.8501225510088638E-002;0.21620211688366087 -0.42823693940249830;1.3295528700280905 0.27892721893609196;1.0842998438472966 -1.2197367054961652;0.28153619668028618 -1.2810993040439602];
%! res = ikeda (10);
%! assert (res, ikd, 1e-16);
tisean-0.2.3/inst/PaxHeaders.27446/xzero.m 0000644 0000000 0000000 00000000131 12563465360 015055 x ustar 00 30 mtime=1439591152.328480792
30 atime=1439591152.328480792
29 ctime=1439591152.98447253
tisean-0.2.3/inst/xzero.m 0000644 0001750 0001750 00000011217 12563465360 016131 0 ustar 00josiah josiah 0000000 0000000 ## Copyright (C) 1996-2015 Piotr Held
##
## This file is part of Octave.
##
## Octave is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public
## License as published by the Free Software Foundation;
## either version 3 of the License, or (at your option) any
## later version.
##
## Octave is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied
## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
## PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public
## License along with Octave; see the file COPYING. If not,
## see .
## -*- texinfo -*-
## @deftypefn{Function File} {output =} xzero (@var{X1}, @var{X2})
## @deftypefnx{Function File} {output =} xzero (@var{X1}, @var{X2}, @var{paramName}, @var{paramValue}, @dots{})
##
## Takes two data sets and fits a zeroth order model of data set 1 (@var{X1})
## to predict data set 2 (@var{X2}) - cross prediction. It then computes the
## error of the model. This is done by searching for all neighbors in @var{X1}
## of the points of set @var{X2} which should be forecasted and taking as their
## images the average of the images of the neighbors. The obtained forecast
## error is normalized to the variance of data set @var{X2}.
##
## @strong{Inputs}
##
## Both @var{X1} and @var{X2} must be present. They must be realvectors
## of the same length.
##
## @strong{Parameters}
##
## @table @var
## @item m
## Embedding dimension [default = 3].
## @item d
## Delay for embedding [default = 1].
## @item n
## The number of points for which the error should be calculated
## [default = all].
## @item k
## Minimum number of neighbors for the fit [default = 30].
## @item r
## The neighborhood size to start with [default = 1e-3].
## @item f
## Factor by which to increase the neighborhood size if not
## enough neighbors were found [default = 1.2].
## @item s
## Steps to be forecast (@code{x2(n+steps) = av(x1(i+steps)}) [default = 1].
## @end table
##
## @strong{Output}
##
## Contains value of parameter '@var{s}' lines. Each line represents the
## forecast error divided by the standard deviation of the second data set
## (@var{X2}). This second data set is the one being forecasted.
##
## @strong{Algorithms}
##
## The algorithms for this functions have been taken from the TISEAN package.
## @end deftypefn
## Author: Piotr Held .
## This function is based on xzero of TISEAN 3.0.1
## https://github.com/heggus/Tisean"
function output = xzero (X1, X2, varargin)
# Initial input validation
if (nargin < 2)
print_usage;
endif
if ((isvector (X1) == false) || (isreal(X1) == false))
error ('Octave:invalid-input-arg', "X1 must be a realvector");
endif
if ((isvector (X2) == false) || (isreal(X2) == false))
error ('Octave:invalid-input-arg', "X2 must be a realvector");
endif
if (length (X1) != length (X2))
error ('Octave:invalid-input-arg', "X1 and X2 must be of same length");
endif
# Default parameters
embdim = 3;
delay = 1;
clength = length (X1);
minn = 30;
eps0 = 1e-3;
epsf = 1.2;
step = 1;
#### Parse the input
p = inputParser ();
p.FunctionName = "xzero";
isPositiveIntScalar = @(x) isreal(x) && isscalar (x) && ...
(x > 0) && (x-round(x) == 0);
isPositiveScalar = @(x) isreal(x) && isscalar (x) && (x > 0);
p.addParamValue ("m", embdim, isPositiveIntScalar);
p.addParamValue ("d", delay, isPositiveIntScalar);
p.addParamValue ("n", clength, isPositiveIntScalar);
p.addParamValue ("k", minn, isPositiveIntScalar);
p.addParamValue ("r", eps0, isPositiveScalar);
p.addParamValue ("f", epsf, isPositiveScalar);
p.addParamValue ("s", step, isPositiveIntScalar);
p.parse (varargin{:});
# Assign input
embdim = p.Results.m;
delay = p.Results.d;
clength = p.Results.n;
minn = p.Results.k;
eps0 = p.Results.r;
epsset = !ismember ("r", p.UsingDefaults);
epsf = p.Results.f;
step = p.Results.s;
output = __xzero__ (X1, X2, embdim, delay, clength, minn, eps0, epsset, ...
epsf, step);
endfunction
%!fail ("xzero(1)");
%!fail ("xzero('a')");
%!test
%! hen = henon(2000)(:,1);
%! hen1 = hen(1:1000);
%! hen2 = hen(1001:end);
%! res_tisean = [1 0.6438699;2 0.9101371;3 0.9752469;4 0.9600329;5 0.9788585;6 0.9937851;7 1.002654;8 0.9973579;9 1.00776;10 1.008823;11 1.016724;12 1.017996;13 1.011284;14 1.005963;15 1.008479;16 1.007647;17 1.009703;18 1.018097;19 1.008374;20 1.006889];
%! out = xzero (hen1,hen2,'m',4,'d',6,'s',20);
%! assert(out, res_tisean(:,2),-1e-6);
tisean-0.2.3/inst/PaxHeaders.27446/henon.m 0000644 0000000 0000000 00000000131 12563465360 015015 x ustar 00 30 mtime=1439591152.320480892
30 atime=1439591152.320480892
29 ctime=1439591152.98447253
tisean-0.2.3/inst/henon.m 0000644 0001750 0001750 00000007016 12563465360 016073 0 ustar 00josiah josiah 0000000 0000000 ## Copyright (C) 1996-2015 Piotr Held
##
## This file is part of Octave.
##
## Octave is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public
## License as published by the Free Software Foundation;
## either version 3 of the License, or (at your option) any
## later version.
##
## Octave is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied
## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
## PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public
## License along with Octave; see the file COPYING. If not,
## see .
## Author: Piotr Held .
## This function is based on henon of TISEAN 3.0.1 https://github.com/heggus/Tisean"
## -*- texinfo -*-
## @deftypefn{Function File} {@var{output_array} =} henon (@var{L}, @dots{})
## @deftypefnx{Function File} {@var{output_array} =} henon (@var{L}, @var{paramName}, @var{paramValue}, @dots{})
##
## Generate Henon map
##
## @iftex
## @tex
## $$ x_{n+1} = 1 - ax_n^2 + by_n $$
## $$ y_{n+1} = x_n$$
## @end tex
## @end iftex
## @ifnottex
## @example
## x(n+1) = 1 - a * x(n) * x(n) + b * y(n)
## y(n+1) = x(n)
## @end example
## @end ifnottex
##
## @strong{Input}
##
## @table @var
## @item L
## The number of points (x,y), must be integer. Required value.
## @end table
##
## @strong{Parameters}
##
## @table @var
## @item a
## Defines parameter 'a' (default=1.4)
## @item b
## Defines parameter 'b' (default=0.3)
## @item x
## Initial 'x' (default=0.68587)
## @item y
## Initial 'y' (defaul=0.65876)
## @item ntrans
## Defines number of transient points (default=10000), must be positive
## integer scalar
## @end table
##
## @strong{Output}
##
## @var{output_array} is of length @var{L}. It contains points on the
## Henon Map.
##
## @strong{Usage example}
##
## @code{out = henon(1000, "a", 1.25)}
##
## After this command @var{out} will be a 1000x2 matrix with Henon map
## points as rows. It will generate 1000 points.
##
## @strong{Algorithm}@*
## On basis of TISEAN package henon
## @end deftypefn
## Author: Piotr Held .
## This function is based on henon of TISEAN 3.0.1
## https://github.com/heggus/Tisean"
function output = henon (L, varargin)
% Define default parameters.
a = 1.4;
b = 0.3;
x0 = 0.68587;
y0 = 0.65876;
ntransient = 10000;
isPositiveInteger = @(x) isreal(x) && isscalar (x) && (x > 0) && (x-round(x) == 0);
if (nargin < 1)
print_usage();
elseif (isPositiveInteger (L) != true)
error ('Octave:invalid-input-arg', "L must be a positive integer");
endif
#### Parse the input
p = inputParser ();
p.FunctionName = "henon";
p.addParamValue ("A",a,@isnumeric);
p.addParamValue ("B",b,@isnumeric);
p.addParamValue ("X",x0,@isnumeric);
p.addParamValue ("Y",y0,@isnumeric);
isNonNegative = @(x) isreal(x) && isscalar (x) && (x >= 0) && (x-round(x) == 0);
p.addParamValue ("ntrans",ntransient,isNonNegative);
p.parse (varargin{:});
# Asign input
nmax = L;
a = p.Results.A;
b = p.Results.B;
x0 = p.Results.X;
y0 = p.Results.Y;
ntransient = p.Results.ntrans;
% Computing output
output = __henon__ (nmax, a, b, x0, y0, ntransient);
endfunction
%!test
%! hen = [0.67778; 0.41367; 0.96376; -0.17626; 1.24563; -1.22512; -0.72760; -0.10869; 0.76518; 0.14769];
%! res = henon (10);
%!
%! assert (res(:,1), hen, 1e-5);
tisean-0.2.3/inst/PaxHeaders.27446/c2t.m 0000644 0000000 0000000 00000000131 12563465360 014376 x ustar 00 30 mtime=1439591152.316480943
30 atime=1439591152.316480943
29 ctime=1439591152.98447253
tisean-0.2.3/inst/c2t.m 0000644 0001750 0001750 00000014567 12563465360 015465 0 ustar 00josiah josiah 0000000 0000000 ## Copyright (C) 1996-2015 Piotr Held
##
## This file is part of Octave.
##
## Octave is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public
## License as published by the Free Software Foundation;
## either version 3 of the License, or (at your option) any
## later version.
##
## Octave is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied
## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
## PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public
## License along with Octave; see the file COPYING. If not,
## see .
## -*- texinfo -*-
## @deftypefn{Function File} {@var{output} =} c2t (@var{d2_c1_out})
##
## This program calculates the maximum likelihood estimator (the Takens'
## estimator) from correlation sums of the output of d2 (the 'c2' field of
## the d2 output) or c1 (the 'c1' field of c1 output).
##
## The estimator is calculated using the following equation (the integral
## is computed for the discrete values of C(r) by assuming an exact power
## law between the available points):
##
## @iftex
## @tex
## $$D_T(r)=\frac{C(r)}{\int_{0}^{r}dx\, \frac{C(x)}{x}}$$
## @end tex
## @end iftex
## @ifnottex
## @example
## C(r)
## D (r) = ------------
## T /r C(x)
## | dx ----
## /0 x
## @end example
## @end ifnottex
##
## @strong{Input}
##
## The input needs to be the output of d2 or c1.
##
## @strong{Output}
##
## The output is a struct array of the same length as the input.
## It contains the following fiels:
##
## @table @var
## @item dim
## The dimension for each matrix @var{t}.
## @item t
## Matrix with two columns. The first contains epsilon (the first column
## of field 'c2' from d2 output or field 'c1' from c1 output) and the second
## is the maximum likelihood estimator (Takens' estimator).
## @end table
##
## @seealso{demo c2t, d2, c1, c2g, av_d2}
##
## @strong{Algorithms}
##
## The algorithms for this functions have been taken from the TISEAN package.
## @end deftypefn
## Author: Piotr Held .
## This function is based on c2t of TISEAN 3.0.1
## https://github.com/heggus/Tisean"
function output = c2t (d2_c1_out)
if (nargin != 1)
print_usage;
endif
if (!(isfield (d2_c1_out, "dim") && (isfield (d2_c1_out, "c2") ...
&& isfield (d2_c1_out, "d2") && isfield (d2_c1_out, "h2") ...
|| isfield (d2_c1_out, "c1"))))
error ('Octave:invalid-input-arg', ["d2_c1_out must be the output of ", ...
"d2 or c1"]);
endif
t_out = cell (length (d2_c1_out), 1);
for j = 1:size(d2_c1_out,1)
tmp = d2_c1_out(j);
if (isfield (d2_c1_out, "c2"))
corr_sums = tmp.c2;
elseif (isfield (d2_c1_out, "c1"))
corr_sums = tmp.c1;
# there is no else: we checked in input validation that d2_c1_out has one
# of the above
endif
# Limit to only the first positive correlation sums
# (do not calculate output for any past first negative sum)
idx_lt0 = min (find (corr_sums(:,2) <= 0));
if (!isempty (idx_lt0))
corr_sums = corr_sums(1:idx_lt0-1,:);
endif
[s,idx] = sort (corr_sums(:,1));
emat = log (corr_sums(idx,1));
cmat = log (corr_sums(idx,2));
b = (emat(2:end) .* cmat(1:end-1) .- emat(1:end-1) .* cmat(2:end)) ...
./ (emat(2:end) .- emat(1:end-1));
a = (cmat(2:end) - cmat(1:end-1)) ./ (emat(2:end) - emat(1:end-1));
cint = (exp (b) ./ a) ...
.* (exp (a .* emat(2:end)) - exp (a .* emat(1:end-1)));
# If a(i) == 0 then the right side above is '+/-Inf * (1-1)' which is NaN.
tidx = find (isnan (cint));
cint(tidx) = exp (b(tidx)) .* (emat(tidx+1) - emat(tidx));
cint = cumsum (cint);
t_out{j} = [exp(emat(2:end)),exp(cmat(2:end))./cint];
endfor
output = struct ("dim", {d2_c1_out.dim}.', "t", t_out);
# Below is the same code as above but uses loops
# It is left to easily see what the algorithm does.
# output = d2_c1_out;
# for j = 1:size(d2_c1_out,1)
# tmp = d2_c1_out(j);
# [s,idx] = sort (corr_sums(:,1));
# emat = log (corr_sums(idx,1));
# cmat = log (corr_sums(idx,2));
# c2_out = zeros (length(corr_sums)-1,2);
# cint = 0;
# for i = 2:length(corr_sums)
# b = (emat(i)*cmat(i-1)-emat(i-1)*cmat(i))/(emat(i)-emat(i-1));
# a = (cmat(i)-cmat(i-1))/(emat(i)-emat(i-1));
# if (a != 0)
# cint=cint+(exp(b)/a)*(exp(a*emat(i))-exp(a*emat(i-1)));
# else
# cint=cint+exp(b)*(emat(i)-emat(i-1));
# endif
# c2_out(i-1,1) = exp (emat(i));
# c2_out(i-1,2) = exp (cmat(i))/cint;
# endfor
# output(j).c2 = c2_out;
# endfor
endfunction
%!demo
%! vals = d2 (henon (1000), 'd', 1, 't', 50, 'm', 5);
%! takens = c2t (vals);
%! do_plot_slope = @(x) semilogx (x{1}(:,1),x{1}(:,2),'r');
%! hold on
%! arrayfun (do_plot_slope, {takens.t});
%! hold off
%! axis tight
%! ylim ([0 3]);
%! xlabel ("Epsilon")
%! title ("Takens' Estimator");
%!###############################################################
%!test
%! c2t_res = [0.00274151703 14.7681456;0.00293963822 7.62825966;0.00315207872 5.24064684;0.0033798716 4.0903101;0.00362412469 3.3594861;0.00388602936 2.86986566;0.00416686293 2.51803875;0.00446798978 2.26902509;0.00479088025 2.09245157;0.00513710314 1.94326866;0.00550834602 1.82226741;0.00590642029 1.73174965;0.00633325987 1.63774204;0.00679094903 1.57059276;0.00728171039 1.50973487;0.00780794164 1.455006;0.00837219786 1.40932345;0.00897723623 1.37041831;0.00962599367 1.33392417;0.0103216404 1.29980099];
%! val = d2 (henon (1000), 'd', 1, 't', 50, 'm', 5);
%! res = c2t (val);
%! assert (cell2mat({res.t}.')(1:length(c2t_res),:), c2t_res, -2.51e-5);
%% Check if limiting of negative correlation sums works
%!test
%! c2t_res = [1.20000005 11.9785480;1.29999995 7.00581074;1.50000000 5.05822706;2.00000000 1.75614762];
%! in_c2 = [2 4;1.5 5;1.3 3;1.2 2.5;1.1 2.3;1 -1;0.9 1.3;0.8 1.4;0.7 1.6];
%! in = struct ("dim",1,"c2",in_c2,"d2",0,"h2",0);
%! res = c2t (in);
%! assert (cell2mat({res.t}.'), c2t_res, -1e-5);
%% Check if funciton accepts output from c1 and produces nonzero output
%!test
%! c2t_c1_res = c2t (c1 (henon (1000)));
%! assert (!isequal (c2t_c1_res, []));
%! assert (isfield (c2t_c1_res, "t"));
%% Testing input validation
%!error