[rms,sd,all]=nt_bsrms(x,N) - calculate rms, estimate sd using bootstrap rms: rms over second dimension of x sd: standard deviation of rms calculated by bootstrap all: matrix of all trials x: matrix of observations (time X repetitions) N: number of bootstrap trials [default: 100]
0001 function [rms,sd,all]=nt_bsrms(x,N) 0002 %[rms,sd,all]=nt_bsrms(x,N) - calculate rms, estimate sd using bootstrap 0003 % 0004 % rms: rms over second dimension of x 0005 % sd: standard deviation of rms calculated by bootstrap 0006 % all: matrix of all trials 0007 % 0008 % x: matrix of observations (time X repetitions) 0009 % N: number of bootstrap trials [default: 100] 0010 0011 if nargin <2; N=100; end 0012 0013 if ndims(x)>2; error('data must be at most 2D'); end 0014 0015 [m,n]=size(x); 0016 all=zeros(m,N); 0017 for k=1:N 0018 idx=ceil(n*rand(1,n)); 0019 all(:,k)=sqrt(mean(x(:,idx).^2,2)); 0020 end 0021 0022 rms=sqrt(mean(x.^2,2)); 0023 sd=sqrt(mean((all-repmat(rms,1,N)).^2,2)); 0024 0025