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

📄 bstats.m

📁 bootstrp 抽样方法
💻 M
字号:
function[m,varargout] = bstats(res,varargin)
% JKNIFE     Bootstrapped mean, variance and confidence interval 
% INPUTS  :  res   - array or structure array output by BSTRAP
%            field - if res is a structure array, field storing statistic x
% OUTPUTS  : m     - average of x's bootstrap distribution
%            v     - (optional) variance of bootstrap distribution 
%            cil   - (optional) 2.5%  percentile of bootstrap distribution
%            ciu   - (optional) 97.5% percentile of bootstrap distribution
% EXAMPLE  : See BSTRAPDEMO 
% SEE ALSO : BSTRAP, JKNIFE; JACKKNIFE, BOOTSTRP (Statistics Toolbox)
% 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
            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]);
            for m = 2:n
                x(:,:,m-1) = eval(['[res(m).' field ']']);
            end
         end    
end   
m = mean(x,3);
if nargout > 1
   varargout(1) = {var(x,1,3)};
end   
if nargout > 2
   varargout(2) = {prctile(x,2.5,3)};
end   
if nargout > 3
   varargout(3) = {prctile(x,97.5,3)};
end 

⌨️ 快捷键说明

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