       function [dmean, dstddev,...
                 neff0,itau0,derr0,...
                 neff, itau,derr] = nefftauall(data)
% --------------------------------------------
%       function [dmean, dstddev,...
%                 neff0,itau0,derr0,...
%                 neff, itau,derr] = nefftauall(data)
% for a timeseries data, returns
% - the mean and error of the timeseries
% - the effective number of degrees of freedom and
% - the integral timescale (determined as time
% for auto correlation to fall to 1/e (need to
% take the mean out first, so use xcov
% - also does time for autocov to cross zero
%---------------------------------------------
% 13 Dec 2003  R A Woodgate - created
% --------------------------------------------
%
%cutoff=0.368 .* 0.5;
cutoff=1/exp(1) .* 0.5;	%1/e = 0.368
jjj=xcov(data,'coeff');
%%%jjj=xcov(data,data,'coeff');
istart=min(find(jjj>0.999));
itau=min(find(jjj(istart:end)<=cutoff)) ;
neff=length(data)./itau                   ;
dmean=mean(data);
dstddev=std(data);
derr = dstddev./sqrt(neff);

cutoff=0                                     ;
jjj0=xcov(data,'coeff');                      ;
%%jjj0=xcov(data,data,'coeff');                      ;
istart0=min(find(jjj0>0.999))                  ;
itau0=min(find(jjj0(istart0:end)<=cutoff))      ;
neff0=length(data)./itau0                         ;
derr0 = dstddev./sqrt(neff0)                       ;


