⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jstats.m

📁 Jacknife method, very good
💻 M
字号:
function[m,varargout] = jstats(res,varargin)
% JKNIFE     Jackknifed mean and variance 
% INPUTS  :  res   - array or structure array output by JKNIFEP
%            field - if res is a structure array, field storing statistic x
% OUTPUTS  : m     - jackknife mean estimate
%            v     - (optional) jackknife variance estimate 
% EXAMPLE  : See JKNIFEDEMO 
% SEE ALSO : JKNIFE, BSTRAP; JACKKNIFE, BOOTSTRP (Statistics Toolbox)
% REF.     : Shao and Tu (1995), pp. 5-6
% AUTHOR   : Dimitri Shvorob, dimitri.shvorob@vanderbilt.edu, 4/15/07

switch nargin
    case 0
         error('Input argument "res" is undefined') 
    case 1
         if isstruct(res)
            error('Input argument "field" must be provided if "res" is a structure')
         else
            x0 = res(:,:,1);
            x  = res(:,:,2:end);
         end   
    case 2
         if ~isstruct(res)
            error('Input argument "field" is provided, but "res" is not a structure')
         else
            try 
                field = char(varargin);
            catch
                error('Input argument "field" must be a string')
            end
            try
                x = eval(['res(1).' field]);
            catch
                error(['Field ' field ' not found in "res"'])
            end   
            n = length(res);
            x  = repmat(x,[1 1 n-1]);
            x0 = eval(['[res(1).' field ']']);
            for m = 2:n
                x(:,:,m-1) = eval(['[res(m).' field ']']);
            end
         end    
end
n  = size(x,3);
mj = mean(x,3);
m  = n*x0 - (n-1)*mj;
if nargout > 1
   s = 0;
   for j = 1:n
       d = x(:,:,j) - mj;
       s = s + (d.^2);
   end  
   varargout(1) = {((n-1)/n)*s};
end   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -