Skip to content

Commit

Permalink
A few fixes and new continuous versions of FirstCrossing
Browse files Browse the repository at this point in the history
  • Loading branch information
benfulcher committed Jul 2, 2020
1 parent a7a72c9 commit c74b251
Show file tree
Hide file tree
Showing 47 changed files with 274 additions and 211 deletions.
10 changes: 5 additions & 5 deletions Database/INP_mops.txt
Expand Up @@ -129,8 +129,8 @@ CO_AutoCorr(x_z,37,'Fourier') AC_37
CO_AutoCorr(x_z,38,'Fourier') AC_38
CO_AutoCorr(x_z,39,'Fourier') AC_39
CO_AutoCorr(x_z,40,'Fourier') AC_40
CO_FirstZero(x_z,'ac') CO_FirstZero_ac
CO_f1ecac(x_z) CO_f1ecac
CO_FirstCrossing(x_z,'ac',0,'both') CO_FirstCrossing_acf_0
CO_FirstCrossing(x_z,'ac',1/exp(1),'both') CO_FirstCrossing_acf_1e
CO_FirstMin(x_z,'ac') CO_FirstMin_ac
CO_FirstMin(x_z,'mi-gaussian') CO_FirstMin_mi-gaussian
CO_FirstMin(x_z,'mi-kraskov1','4') CO_FirstMin_mi-kraskov1_4
Expand Down Expand Up @@ -750,9 +750,9 @@ PH_ForcePotential(x_z,'dblwell',[3,0.01,0.1]) PH_ForcePotential_dblwell_3_001_01
PH_ForcePotential(x_z,'sine',[3,0.5,1]) PH_ForcePotential_sine_3_05_1
PH_ForcePotential(x_z,'sine',[1,1,1]) PH_ForcePotential_sine_1_1_1
PH_ForcePotential(x_z,'sine',[10,0.04,10]) PH_ForcePotential_sine_10_004_10
DN_RemovePoints(x_z,'absclose',0.1,'saturate') DN_RemovePoints_absclose_01_saturate
DN_RemovePoints(x_z,'absclose',0.5,'saturate') DN_RemovePoints_absclose_05_saturate
DN_RemovePoints(x_z,'absclose',0.8,'saturate') DN_RemovePoints_absclose_08_saturate
DN_RemovePoints(x_z,'absclose',0.1,'remove') DN_RemovePoints_absclose_01_remove
DN_RemovePoints(x_z,'absclose',0.5,'remove') DN_RemovePoints_absclose_05_remove
DN_RemovePoints(x_z,'absclose',0.8,'remove') DN_RemovePoints_absclose_08_remove
DN_RemovePoints(x_z,'absfar',0.1,'remove') DN_RemovePoints_absfar_01_remove
DN_RemovePoints(x_z,'absfar',0.8,'remove') DN_RemovePoints_absfar_08_remove
DN_RemovePoints(x_z,'absfar',0.1,'saturate') DN_RemovePoints_absfar_01_saturate
Expand Down
86 changes: 44 additions & 42 deletions Database/INP_ops.txt
Expand Up @@ -130,9 +130,11 @@ AC_37 AC_37 correlation
AC_38 AC_38 correlation
AC_39 AC_39 correlation
AC_40 AC_40 correlation
CO_FirstZero_ac first_zero_ac correlation,tau
CO_f1ecac first_1e_ac correlation,tau
CO_FirstMin_ac first_min_acf correlation,tau
CO_FirstCrossing_acf_0.firstCrossing firstZero_acf_tau correlation,timescale
CO_FirstCrossing_acf_0.pointOfCrossing firstZero_acf_point correlation,timescale
CO_FirstCrossing_acf_1e.firstCrossing first1e_acf_tau correlation,timescale
CO_FirstCrossing_acf_1e.pointOfCrossing first1e_acf_point correlation,timescale
CO_FirstMin_ac firstMin_acf correlation,timescale
AC_nl_12 AC_nl_12 correlation,nonlinearautocorr
AC_nl_123 AC_nl_123 correlation,nonlinearautocorr
AC_nl_1234 AC_nl_1234 correlation,nonlinearautocorr
Expand Down Expand Up @@ -1683,45 +1685,45 @@ PH_ForcePotential_sine_10_004_10.ac50 PH_ForcePotential_sine_10_004_10_ac50 dyna
PH_ForcePotential_sine_10_004_10.tau PH_ForcePotential_sine_10_004_10_tau dynamicalSystem
PH_ForcePotential_sine_10_004_10.finaldev PH_ForcePotential_sine_10_004_10_finaldev dynamicalSystem
PH_ForcePotential_sine_10_004_10.std PH_ForcePotential_sine_10_004_10_std dynamicalSystem
DN_RemovePoints_absclose_01_saturate.fzcacrat DN_RemovePoints_absclose_01_saturate_fzcacrat correlation,outliers
DN_RemovePoints_absclose_01_saturate.ac1rat DN_RemovePoints_absclose_01_saturate_ac1rat correlation,outliers
DN_RemovePoints_absclose_01_saturate.ac1diff DN_RemovePoints_absclose_01_saturate_ac1diff correlation,outliers
DN_RemovePoints_absclose_01_saturate.ac2rat DN_RemovePoints_absclose_01_saturate_ac2rat correlation,outliers
DN_RemovePoints_absclose_01_saturate.ac2diff DN_RemovePoints_absclose_01_saturate_ac2diff correlation,outliers
DN_RemovePoints_absclose_01_saturate.ac3rat DN_RemovePoints_absclose_01_saturate_ac3rat correlation,outliers
DN_RemovePoints_absclose_01_saturate.ac3diff DN_RemovePoints_absclose_01_saturate_ac3diff correlation,outliers
DN_RemovePoints_absclose_01_saturate.sumabsacfdiff DN_RemovePoints_absclose_01_saturate_sumabsacfdiff correlation,outliers
DN_RemovePoints_absclose_01_saturate.mean DN_RemovePoints_absclose_01_saturate_mean correlation,outliers
DN_RemovePoints_absclose_01_saturate.median DN_RemovePoints_absclose_01_saturate_median correlation,outliers
DN_RemovePoints_absclose_01_saturate.std DN_RemovePoints_absclose_01_saturate_std correlation,outliers
DN_RemovePoints_absclose_01_saturate.skewnessrat DN_RemovePoints_absclose_01_saturate_skewnessrat correlation,outliers,distribution
DN_RemovePoints_absclose_01_saturate.kurtosisrat DN_RemovePoints_absclose_01_saturate_kurtosisrat correlation,outliers,distribution
DN_RemovePoints_absclose_05_saturate.fzcacrat DN_RemovePoints_absclose_05_saturate_fzcacrat correlation,outliers
DN_RemovePoints_absclose_05_saturate.ac1rat DN_RemovePoints_absclose_05_saturate_ac1rat correlation,outliers
DN_RemovePoints_absclose_05_saturate.ac1diff DN_RemovePoints_absclose_05_saturate_ac1diff correlation,outliers
DN_RemovePoints_absclose_05_saturate.ac2rat DN_RemovePoints_absclose_05_saturate_ac2rat correlation,outliers
DN_RemovePoints_absclose_05_saturate.ac2diff DN_RemovePoints_absclose_05_saturate_ac2diff correlation,outliers
DN_RemovePoints_absclose_05_saturate.ac3rat DN_RemovePoints_absclose_05_saturate_ac3rat correlation,outliers
DN_RemovePoints_absclose_05_saturate.ac3diff DN_RemovePoints_absclose_05_saturate_ac3diff correlation,outliers
DN_RemovePoints_absclose_05_saturate.sumabsacfdiff DN_RemovePoints_absclose_05_saturate_sumabsacfdiff correlation,outliers
DN_RemovePoints_absclose_05_saturate.mean DN_RemovePoints_absclose_05_saturate_mean correlation,outliers
DN_RemovePoints_absclose_05_saturate.median DN_RemovePoints_absclose_05_saturate_median correlation,outliers
DN_RemovePoints_absclose_05_saturate.std DN_RemovePoints_absclose_05_saturate_std correlation,outliers
DN_RemovePoints_absclose_05_saturate.skewnessrat DN_RemovePoints_absclose_05_saturate_skewnessrat correlation,outliers,distribution
DN_RemovePoints_absclose_05_saturate.kurtosisrat DN_RemovePoints_absclose_05_saturate_kurtosisrat correlation,outliers,distribution
DN_RemovePoints_absclose_08_saturate.fzcacrat DN_RemovePoints_absclose_08_saturate_fzcacrat correlation,outliers
DN_RemovePoints_absclose_08_saturate.ac1rat DN_RemovePoints_absclose_08_saturate_ac1rat correlation,outliers
DN_RemovePoints_absclose_08_saturate.ac1diff DN_RemovePoints_absclose_08_saturate_ac1diff correlation,outliers
DN_RemovePoints_absclose_08_saturate.ac2rat DN_RemovePoints_absclose_08_saturate_ac2rat correlation,outliers
DN_RemovePoints_absclose_08_saturate.ac2diff DN_RemovePoints_absclose_08_saturate_ac2diff correlation,outliers
DN_RemovePoints_absclose_08_saturate.ac3rat DN_RemovePoints_absclose_08_saturate_ac3rat correlation,outliers
DN_RemovePoints_absclose_08_saturate.ac3diff DN_RemovePoints_absclose_08_saturate_ac3diff correlation,outliers
DN_RemovePoints_absclose_08_saturate.sumabsacfdiff DN_RemovePoints_absclose_08_saturate_sumabsacfdiff correlation,outliers
DN_RemovePoints_absclose_08_saturate.mean DN_RemovePoints_absclose_08_saturate_mean correlation,outliers
DN_RemovePoints_absclose_08_saturate.median DN_RemovePoints_absclose_08_saturate_median correlation,outliers
DN_RemovePoints_absclose_08_saturate.std DN_RemovePoints_absclose_08_saturate_std correlation,outliers
DN_RemovePoints_absclose_08_saturate.skewnessrat DN_RemovePoints_absclose_08_saturate_skewnessrat correlation,outliers,distribution
DN_RemovePoints_absclose_08_saturate.kurtosisrat DN_RemovePoints_absclose_08_saturate_kurtosisrat correlation,outliers,distribution
DN_RemovePoints_absclose_01_remove.fzcacrat DN_RemovePoints_absclose_01_remove_fzcacrat correlation,outliers
DN_RemovePoints_absclose_01_remove.ac1rat DN_RemovePoints_absclose_01_remove_ac1rat correlation,outliers
DN_RemovePoints_absclose_01_remove.ac1diff DN_RemovePoints_absclose_01_remove_ac1diff correlation,outliers
DN_RemovePoints_absclose_01_remove.ac2rat DN_RemovePoints_absclose_01_remove_ac2rat correlation,outliers
DN_RemovePoints_absclose_01_remove.ac2diff DN_RemovePoints_absclose_01_remove_ac2diff correlation,outliers
DN_RemovePoints_absclose_01_remove.ac3rat DN_RemovePoints_absclose_01_remove_ac3rat correlation,outliers
DN_RemovePoints_absclose_01_remove.ac3diff DN_RemovePoints_absclose_01_remove_ac3diff correlation,outliers
DN_RemovePoints_absclose_01_remove.sumabsacfdiff DN_RemovePoints_absclose_01_remove_sumabsacfdiff correlation,outliers
DN_RemovePoints_absclose_01_remove.mean DN_RemovePoints_absclose_01_remove_mean correlation,outliers
DN_RemovePoints_absclose_01_remove.median DN_RemovePoints_absclose_01_remove_median correlation,outliers
DN_RemovePoints_absclose_01_remove.std DN_RemovePoints_absclose_01_remove_std correlation,outliers
DN_RemovePoints_absclose_01_remove.skewnessrat DN_RemovePoints_absclose_01_remove_skewnessrat correlation,outliers,distribution
DN_RemovePoints_absclose_01_remove.kurtosisrat DN_RemovePoints_absclose_01_remove_kurtosisrat correlation,outliers,distribution
DN_RemovePoints_absclose_05_remove.fzcacrat DN_RemovePoints_absclose_05_remove_fzcacrat correlation,outliers
DN_RemovePoints_absclose_05_remove.ac1rat DN_RemovePoints_absclose_05_remove_ac1rat correlation,outliers
DN_RemovePoints_absclose_05_remove.ac1diff DN_RemovePoints_absclose_05_remove_ac1diff correlation,outliers
DN_RemovePoints_absclose_05_remove.ac2rat DN_RemovePoints_absclose_05_remove_ac2rat correlation,outliers
DN_RemovePoints_absclose_05_remove.ac2diff DN_RemovePoints_absclose_05_remove_ac2diff correlation,outliers
DN_RemovePoints_absclose_05_remove.ac3rat DN_RemovePoints_absclose_05_remove_ac3rat correlation,outliers
DN_RemovePoints_absclose_05_remove.ac3diff DN_RemovePoints_absclose_05_remove_ac3diff correlation,outliers
DN_RemovePoints_absclose_05_remove.sumabsacfdiff DN_RemovePoints_absclose_05_remove_sumabsacfdiff correlation,outliers
DN_RemovePoints_absclose_05_remove.mean DN_RemovePoints_absclose_05_remove_mean correlation,outliers
DN_RemovePoints_absclose_05_remove.median DN_RemovePoints_absclose_05_remove_median correlation,outliers
DN_RemovePoints_absclose_05_remove.std DN_RemovePoints_absclose_05_remove_std correlation,outliers
DN_RemovePoints_absclose_05_remove.skewnessrat DN_RemovePoints_absclose_05_remove_skewnessrat correlation,outliers,distribution
DN_RemovePoints_absclose_05_remove.kurtosisrat DN_RemovePoints_absclose_05_remove_kurtosisrat correlation,outliers,distribution
DN_RemovePoints_absclose_08_remove.fzcacrat DN_RemovePoints_absclose_08_remove_fzcacrat correlation,outliers
DN_RemovePoints_absclose_08_remove.ac1rat DN_RemovePoints_absclose_08_remove_ac1rat correlation,outliers
DN_RemovePoints_absclose_08_remove.ac1diff DN_RemovePoints_absclose_08_remove_ac1diff correlation,outliers
DN_RemovePoints_absclose_08_remove.ac2rat DN_RemovePoints_absclose_08_remove_ac2rat correlation,outliers
DN_RemovePoints_absclose_08_remove.ac2diff DN_RemovePoints_absclose_08_remove_ac2diff correlation,outliers
DN_RemovePoints_absclose_08_remove.ac3rat DN_RemovePoints_absclose_08_remove_ac3rat correlation,outliers
DN_RemovePoints_absclose_08_remove.ac3diff DN_RemovePoints_absclose_08_remove_ac3diff correlation,outliers
DN_RemovePoints_absclose_08_remove.sumabsacfdiff DN_RemovePoints_absclose_08_remove_sumabsacfdiff correlation,outliers
DN_RemovePoints_absclose_08_remove.mean DN_RemovePoints_absclose_08_remove_mean correlation,outliers
DN_RemovePoints_absclose_08_remove.median DN_RemovePoints_absclose_08_remove_median correlation,outliers
DN_RemovePoints_absclose_08_remove.std DN_RemovePoints_absclose_08_remove_std correlation,outliers
DN_RemovePoints_absclose_08_remove.skewnessrat DN_RemovePoints_absclose_08_remove_skewnessrat correlation,outliers,distribution
DN_RemovePoints_absclose_08_remove.kurtosisrat DN_RemovePoints_absclose_08_remove_kurtosisrat correlation,outliers,distribution
DN_RemovePoints_absfar_01_remove.fzcacrat DN_RemovePoints_absfar_01_remove_fzcacrat correlation,outliers
DN_RemovePoints_absfar_01_remove.ac1rat DN_RemovePoints_absfar_01_remove_ac1rat correlation,outliers
DN_RemovePoints_absfar_01_remove.ac1diff DN_RemovePoints_absfar_01_remove_ac1diff correlation,outliers
Expand Down
2 changes: 1 addition & 1 deletion Operations/CO_AddNoise.m
Expand Up @@ -82,7 +82,7 @@
end
% Set tau to minimum of autocorrelation function
if ~isempty(tau) && ischar(tau) && ismember(tau,{'ac','tau'})
tau = CO_FirstZero(y,'ac');
tau = CO_FirstCrossing(y,'ac',0,'discrete');
end
if nargin < 3
amiMethod = 'even'; % using evenly spaced bins in CO_HistogramAMI
Expand Down
2 changes: 1 addition & 1 deletion Operations/CO_AutoCorrShape.m
Expand Up @@ -155,7 +155,7 @@
if all(acf > 0)
out.actau = NaN;
else
out.actau = CO_AutoCorr(acf,CO_FirstZero(acf,'ac'),'Fourier');
out.actau = CO_AutoCorr(acf,CO_FirstCrossing(acf,'ac',0,'discrete'),'Fourier');
end
else
out.ac1 = NaN;
Expand Down
2 changes: 1 addition & 1 deletion Operations/CO_Embed2.m
Expand Up @@ -54,7 +54,7 @@

% Set tau to the first zero-crossing of the autocorrelation function, with the 'tau' input
if strcmp(tau,'tau'),
tau = CO_FirstZero(y,'ac');
tau = CO_FirstCrossing(y,'ac',0,'discrete');
if tau > length(y)/10
tau = floor(length(y)/10);
end
Expand Down
2 changes: 1 addition & 1 deletion Operations/CO_Embed2_Basic.m
Expand Up @@ -46,7 +46,7 @@

if strcmp(tau,'tau')
% Make tau the first zero crossing of the autocorrelation function
tau = CO_FirstZero(y,'ac');
tau = CO_FirstCrossing(y,'ac',0,'discrete');
end

xt = y(1:end-tau); % part of the time series
Expand Down
2 changes: 1 addition & 1 deletion Operations/CO_Embed2_Dist.m
Expand Up @@ -52,7 +52,7 @@
tau = 'tau'; % set to the first minimum of autocorrelation function
end
if strcmp(tau,'tau'),
tau = CO_FirstZero(y,'ac');
tau = CO_FirstCrossing(y,'ac',0,'discrete');
if tau > N/10
tau = floor(N/10);
end
Expand Down
4 changes: 2 additions & 2 deletions Operations/CO_Embed2_Shapes.m
Expand Up @@ -66,7 +66,7 @@

% Can set time lag equal to first zero crossing of the autocorrelation function with the 'tau' input
if strcmp(tau,'tau'),
tau = CO_FirstZero(y,'ac');
tau = CO_FirstCrossing(y,'ac',0,'discrete');
% Cannot set the time delay greater than 10% the length of the time series
if tau > length(y)/10
tau = floor(length(y)/10);
Expand Down Expand Up @@ -125,7 +125,7 @@
out.ac1 = CO_AutoCorr(counts,1,'Fourier');
out.ac2 = CO_AutoCorr(counts,2,'Fourier');
out.ac3 = CO_AutoCorr(counts,3,'Fourier');
out.tau = CO_FirstZero(counts,'ac');
out.tau = CO_FirstCrossing(counts,'ac',0,'continuous');
out.max = max(counts);
out.std = std(counts);
out.median = median(counts);
Expand Down
46 changes: 25 additions & 21 deletions Operations/CO_FirstZero.m → Operations/CO_FirstCrossing.m
@@ -1,17 +1,13 @@
function out = CO_FirstZero(y,corrFun,maxTau)
% CO_FirstZero The first zero-crossing of a given autocorrelation function
function out = CO_FirstCrossing(y,corrFun,threshold,whatOut)
% CO_FirstCrossing The first crossing of a given autocorrelation across a given threshold
%
%---INPUTS:
%
% y, the input time series
% corrFun, the self-correlation function to measure:
% (i) 'ac': normal linear autocorrelation function. Uses CO_AutoCorr to
% calculate autocorrelations.
% maxTau, a maximum time-delay to search up to.
%
% In future, could add an option to return the point at which the function
% crosses the axis, rather than the first integer lag at which it has already
% crossed (what is currently implemented).
% threshold, to cross: e.g., 0, 1/exp(1).

% ------------------------------------------------------------------------------
% Copyright (C) 2020, Ben D. Fulcher <ben.d.fulcher@gmail.com>,
Expand Down Expand Up @@ -49,34 +45,42 @@
N = length(y); % the length of the time series

if nargin < 2 || isempty(corrFun)
corrFun = 'ac'; % autocorrelation by default
corrFun = 'ac'; % linear autocorrelation function
end
if nargin < 3 || isempty(threshold)
threshold = 0;
end
if nargin < 3 || isempty(maxTau)
maxTau = N; % search up to a maximum of the length of the time series
% maxTau = 400; % searches up to this maximum time lag
% maxTau = min(maxTau,N); % searched up to the length of the time series if this is less than maxTau
if nargin < 4 || isempty(whatOut)
whatOut = 'both';
end

% ------------------------------------------------------------------------------
%-------------------------------------------------------------------------------
% Select the self-correlation function as an inline function
% Eventually could add additional self-correlation functions
switch corrFun
case 'ac'
% Autocorrelation at all time lags
corrs = CO_AutoCorr(y,[],'Fourier');
corrs = corrs(2:end); % remove the zero-lag result
otherwise
error('Unknown correlation function ''%s''',corrFun);
end

% Calculate autocorrelation at increasing lags, until you find a negative one
for tau = 1:maxTau-1
if corrs(tau) < 0 % we know it starts positive (1), so first negative will be the zero-crossing
out = tau; return
end
%-------------------------------------------------------------------------------
% Calculate point of crossing:
[firstCrossingIndex, pointOfCrossingIndex] = BF_PointOfCrossing(corrs,threshold);

%-------------------------------------------------------------------------------
% Assemble the appropriate output (structure or double):
% Convert from index space (1,2,…) to lag space (0,1,2,…):
switch whatOut
case 'both'
out.firstCrossing = firstCrossingIndex - 1;
out.pointOfCrossing = pointOfCrossingIndex - 1;
case 'discrete'
out = firstCrossingIndex - 1;
case 'continuous'
out = pointOfCrossingIndex - 1;
end

% If haven't left yet, set output to maxTau
out = maxTau;

end
5 changes: 3 additions & 2 deletions Operations/CO_FirstMin.m
Expand Up @@ -11,7 +11,7 @@
% or 'mi-hist' (histogram-based method).
%
% Note that selecting 'ac' is unusual operation: standard operations are the
% first zero-crossing of the autocorrelation (as in CO_FirstZero), or the first
% first zero-crossing of the autocorrelation (as in CO_FirstCrossing), or the first
% minimum of the mutual information function ('mi').

% ------------------------------------------------------------------------------
Expand Down Expand Up @@ -92,7 +92,8 @@
% Hit a NaN before got to a minimum -- there is no minimum
if isnan(autoCorr(i))
warning('No minimum in %s [[time series too short to find it?]]',minWhat)
out = NaN; return
out = NaN;
return
end

% We're at a minimum:
Expand Down
2 changes: 1 addition & 1 deletion Operations/CO_HistogramAMI.m
Expand Up @@ -62,7 +62,7 @@
tau = 1; % time-lag of 1
end
if ischar(tau) && ismember(tau,{'ac','tau'})
tau = CO_FirstZero(y,'ac');
tau = CO_FirstCrossing(y,'ac',0,'discrete');
end

if nargin < 3 || isempty(meth)
Expand Down
14 changes: 8 additions & 6 deletions Operations/CO_StickAngles.m
Expand Up @@ -235,22 +235,22 @@

%% correlations?
if ~isempty(zangles{1});
out.tau_p = CO_FirstZero(zangles{1},'ac');
out.tau_p = CO_FirstCrossing(zangles{1},'ac',0,'continuous');
out.ac1_p = CO_AutoCorr(zangles{1},1,'Fourier');
out.ac2_p = CO_AutoCorr(zangles{1},2,'Fourier');
else
out.tau_p = NaN; out.ac1_p = NaN; out.ac2_p = NaN;
end

if ~isempty(zangles{2});
out.tau_n = CO_FirstZero(zangles{2},'ac');
out.tau_n = CO_FirstCrossing(zangles{2},'ac',0,'continuous');
out.ac1_n = CO_AutoCorr(zangles{2},1,'Fourier');
out.ac2_n = CO_AutoCorr(zangles{2},2,'Fourier');
else
out.tau_n=NaN; out.ac1_n = NaN; out.ac2_n = NaN;
end

out.tau_all = CO_FirstZero(zallAngles,'ac');
out.tau_all = CO_FirstCrossing(zallAngles,'ac',0,'continuous');
out.ac1_all = CO_AutoCorr(zallAngles,1,'Fourier');
out.ac2_all = CO_AutoCorr(zallAngles,2,'Fourier');

Expand Down Expand Up @@ -292,9 +292,8 @@
out.skewness_all = skewness(allAngles);
out.kurtosis_all = kurtosis(allAngles);

%% Outliers?
% forget about this, I think.

%-------------------------------------------------------------------------------
function [statavmean, statavstd] = SUB_statav(x,n)
% Does a n-partition statav.
% Require 2*n points (i.e., minimum of 2 in each partition) to do a
Expand All @@ -306,7 +305,10 @@
end

x_buff = buffer(x,floor(NN/n));
if size(x_buff,2) > n, x_buff = x_buff(:,1:n); end % lose last point
if size(x_buff,2) > n
% Remove final point
x_buff = x_buff(:,1:n);
end
statavmean = std(mean(x_buff))/std(x);
statavstd = std(std(x_buff))/std(x);
end
Expand Down
2 changes: 1 addition & 1 deletion Operations/CO_glscf.m
Expand Up @@ -56,7 +56,7 @@

% Set tau to first zero-crossing of the autocorrelation function with the input 'tau'
if strcmp(tau,'tau')
tau = CO_FirstZero(y,'ac');
tau = CO_FirstCrossing(y,'ac',0,'discrete');
end

% Take magnitudes of time-delayed versions of the time series:
Expand Down
2 changes: 1 addition & 1 deletion Operations/CO_tc3.m
Expand Up @@ -60,7 +60,7 @@
% ------------------------------------------------------------------------------
% Can set the time lag, tau, to be 'ac' or 'mi'
if strcmp(tau,'ac')
tau = CO_FirstZero(y,'ac');
tau = CO_FirstCrossing(y,'ac',0,'discrete');
% tau is first zero crossing of the autocorrelation function
elseif strcmp(tau,'mi')
tau = CO_FirstMin(y,'mi');
Expand Down

0 comments on commit c74b251

Please sign in to comment.