📄 bstats.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 + -