Compute jackknife estimates of the mean and standard deviation of input data x Usage: [m,jsd]=jackknife(x) Inputs: x : data in the form samples x trials Outputs: m : estimate of the mean (across trials) jsd: jackknife estimate of the standard deviation (across trials)
0001 function [m,jsd]=jackknife(x) 0002 % Compute jackknife estimates of the mean and standard deviation of input data x 0003 % Usage: [m,jsd]=jackknife(x) 0004 % 0005 % Inputs: 0006 % x : data in the form samples x trials 0007 % 0008 % Outputs: 0009 % m : estimate of the mean (across trials) 0010 % jsd: jackknife estimate of the standard deviation (across trials) 0011 0012 [N,C]=size(x); 0013 if C==1; error('Need multiple trials'); end; 0014 m=mean(x,2); 0015 theta=zeros(N,C); 0016 for tr=1:C; 0017 i=setdiff((1:C),tr); % drop 1 trial 0018 y=sum(x(:,i),2)/(C-1); % mean over remaining trials 0019 theta(:,tr)=C*m-(C-1)*y; % pseudo values 0020 % yy(:,tr)=y; 0021 end; 0022 jm=mean(theta,2); 0023 jm=repmat(jm,[1 C]); 0024 % jm2=mean(yy,2); 0025 % jm2=repmat(jm2,[1 C]); 0026 jsd=sqrt(sum((theta-jm).^2,2)/(C*(C-1))); 0027 % jsd2=sqrt((C-1)*sum((yy-jm2).^2,2)/C); 0028 % jsd 0029 % jsd2