Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CRP Toolbox for MATLAB
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Norbert Marwan
CRP Toolbox for MATLAB
Commits
3ec33ec9
Commit
3ec33ec9
authored
9 years ago
by
marwan
Browse files
Options
Downloads
Patches
Plain Diff
added support for multi-column phase space vectors
parent
f9ea45fb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
twinsurr.m
+35
-25
35 additions, 25 deletions
twinsurr.m
with
35 additions
and
25 deletions
twinsurr.m
+
35
−
25
View file @
3ec33ec9
...
@@ -45,6 +45,9 @@ function [y nTw] = twinsurr(varargin)
...
@@ -45,6 +45,9 @@ function [y nTw] = twinsurr(varargin)
% $Revision$
% $Revision$
%
%
% $Log$
% $Log$
% Revision 5.5 2016/03/01 15:56:47 marwan
% complete recoding based on an implementation by Maik Riedl (much faster calculations)
%
% Revision 5.4 2009/03/24 08:33:47 marwan
% Revision 5.4 2009/03/24 08:33:47 marwan
% copyright address changed
% copyright address changed
%
%
...
@@ -148,19 +151,20 @@ end
...
@@ -148,19 +151,20 @@ end
if
size
(
x
,
1
)
<
size
(
x
,
2
),
x
=
x
'
;
end
if
size
(
x
,
1
)
<
size
(
x
,
2
),
x
=
x
'
;
end
if
size
(
x
,
2
)
>
1
if
size
(
x
,
2
)
>
1
&
m
>
1
warning
(
'
M
ulticolumn vectors
are
not supported.
Only first column will be used
.'
)
warning
(
'
Embedding for m
ulti
-
column
phase space
vectors
is
not supported.
Continue without embedding
.'
)
x
=
x
(:,
1
)
;
m
=
1
;
end
end
N
=
length
(
x
);
N
=
length
(
x
);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% main part: create surrogates
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% main part: create surrogates
if
size
(
x
,
2
)
>
1
surr
=
zeros
(
N
,
nsur
);
surr
=
zeros
(
N
,
size
(
x
,
2
),
nsur
);
else
surr
=
zeros
(
N
,
nsur
);
end
%% find twins
%% find twins
h
=
[];
h
=
[];
...
@@ -169,6 +173,7 @@ twinList = findTwins(x,m,t,e,method,nonorm,sil,h);
...
@@ -169,6 +173,7 @@ twinList = findTwins(x,m,t,e,method,nonorm,sil,h);
nTwins
=
length
(
twinList
);
% number of twins
nTwins
=
length
(
twinList
);
% number of twins
if
nTwins
<
1
if
nTwins
<
1
if
~
sil
&
exist
(
'h'
)
&
ishandle
(
h
),
close
(
h
),
end
error
([
'No twins found!'
,
10
,
'The derived surrogates would identical with the original data.'
]
'
)
error
([
'No twins found!'
,
10
,
'The derived surrogates would identical with the original data.'
]
'
)
end
end
...
@@ -203,8 +208,12 @@ while cnt < nsur
...
@@ -203,8 +208,12 @@ while cnt < nsur
end
end
if
length
(
idxSurr
)
==
N
if
length
(
idxSurr
)
==
N
cnt
=
cnt
+
1
;
cnt
=
cnt
+
1
;
surr
(:,
cnt
)
=
x
(
idxSurr
);
if
size
(
x
,
2
)
>
1
if
~
sil
&
exist
(
'h'
)
&
mod
(
cnt
,
100
)
==
0
surr
(:,:,
cnt
)
=
x
(
idxSurr
,:);
else
surr
(:,
cnt
)
=
x
(
idxSurr
,:);
end
if
~
sil
&
~
isempty
(
h
)
&
mod
(
cnt
,
100
)
==
0
waitbar
((
2
*
N
+
N
*
cnt
/
nsur
)/(
3
*
N
),
h
,
'Create surrogates'
)
waitbar
((
2
*
N
+
N
*
cnt
/
nsur
)/(
3
*
N
),
h
,
'Create surrogates'
)
end
end
end
end
...
@@ -213,7 +222,7 @@ end
...
@@ -213,7 +222,7 @@ end
if
~
sil
&
exist
(
'h'
)
&
ishandle
(
h
),
close
(
h
),
end
if
~
sil
&
exist
(
'h'
)
&
ishandle
(
h
),
close
(
h
),
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% output
if
nargout
>
0
;
if
nargout
>
0
;
y
=
surr
;
y
=
surr
;
else
else
...
@@ -227,12 +236,7 @@ end
...
@@ -227,12 +236,7 @@ end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% helper function (findTwins)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function
twinList
=
findTwins
(
x
,
m
,
t
,
thr
,
method
,
nonorm
,
sil
,
h
)
function
twinList
=
findTwins
(
x
,
m
,
t
,
thr
,
method
,
nonorm
,
sil
,
h
)
...
@@ -248,7 +252,6 @@ function twinList=findTwins(x,m,t,thr,method,nonorm,sil,h)
...
@@ -248,7 +252,6 @@ function twinList=findTwins(x,m,t,thr,method,nonorm,sil,h)
%threshold THR.
%threshold THR.
%Twins are points with the same neighbourhood.
%Twins are points with the same neighbourhood.
%% Reconstruct phase space
if
nonorm
if
nonorm
if
~
sil
,
disp
(
'Normalize data.'
),
end
if
~
sil
,
disp
(
'Normalize data.'
),
end
x
=
zscore
(
x
);
x
=
zscore
(
x
);
...
@@ -256,12 +259,19 @@ end
...
@@ -256,12 +259,19 @@ end
updateTime
=
100
;
updateTime
=
100
;
N
=
length
(
x
);
N
=
length
(
x
);
Nx
=
N
-
(
m
-
1
)
*
t
;
xEmb
=
zeros
(
Nx
,
m
);
for
i
=
1
:
m
xEmb
(:,
i
)
=
x
(((
i
-
1
)
*
t
+
1
):(
end
-
t
*
(
m
-
i
)));
end
%% Reconstruct phase space if m is set
if
m
>
1
Nx
=
N
-
(
m
-
1
)
*
t
;
xEmb
=
zeros
(
Nx
,
m
);
for
i
=
1
:
m
xEmb
(:,
i
)
=
x
(((
i
-
1
)
*
t
+
1
):(
end
-
t
*
(
m
-
i
)));
end
else
xEmb
=
x
;
Nx
=
N
;
end
%% Find recurrence points (= neighbours) for each state
%% Find recurrence points (= neighbours) for each state
% this is a list of neighbours for each time point/state
% this is a list of neighbours for each time point/state
idxNeighbours
=
[];
idxNeighbours
=
[];
...
@@ -270,11 +280,11 @@ for i = 1:Nx, if ~sil & ~isempty(h) & mod(i,updateTime)==0, waitbar(i/(3*N)), en
...
@@ -270,11 +280,11 @@ for i = 1:Nx, if ~sil & ~isempty(h) & mod(i,updateTime)==0, waitbar(i/(3*N)), en
% distance between current state and all other states
% distance between current state and all other states
switch
method
switch
method
case
'eu'
case
'eu'
d
=
sqrt
(
sum
((
xEmb
(
1
:
end
,:)
-
xEmb
(
i
,:))
.^
2
,
2
));
d
=
sqrt
(
sum
((
xEmb
-
repmat
(
xEmb
(
i
,:)
,
Nx
,
1
)
)
.^
2
,
2
));
case
'mi'
case
'mi'
d
=
sum
(
abs
(
xEmb
(
1
:
end
,:)
-
xEmb
(
i
,:)),
2
);
d
=
sum
(
abs
(
xEmb
-
repmat
(
xEmb
(
i
,:)
,
Nx
,
1
)
),
2
);
otherwise
otherwise
d
=
max
(
abs
(
xEmb
(
1
:
end
,:)
-
xEmb
(
i
,:)),[],
2
);
d
=
max
(
abs
(
xEmb
-
repmat
(
xEmb
(
i
,:)
,
Nx
,
1
)
),[],
2
);
end
end
% indices of the Neighbours
% indices of the Neighbours
idxNeighbours
{
i
}
=
find
(
d
<
thr
);
idxNeighbours
{
i
}
=
find
(
d
<
thr
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment