Bootci usage: passing vectors into function
11 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I am trying to use bootci to generate confidence intervals on a fit to data. My code is:
[ci,bootstat] = bootci(100,{fitData,data,v1,v2,scalar},'alpha',.1)
where fitData is a function that returns a scalar from the fit to data (data is the set to be sampled with replacement). The variables v1 and v2 (two vectors) and one scalar are needed by the function.
As I understand it, the problem is that the function, fitData, also needs those two vectors v1 and v2. However, I do not wish to sample from. My understanding from the documentation is bootstrp and bootci automatically samples from all vectors passed to the function. Is this correct? If it is, is there a way to change that?
Thanks, Gabriela
0 件のコメント
採用された回答
Oleg Komarov
2012 年 4 月 5 日
% Inputs
y = randn(100,1);
v1 = 1:10;
v2 = 10:-1:1;
% Only 'x' is the input since we fix v1 and v2 (same name as vars)
f = @(x) foo(v1,v2,x);
% Bootstrap f by sampling from y (the only input x)
ci = bootci(2000,{f,y},'alpha',.1);
Where foo is
function out = foo(in1,in2,data)
out = sum(in1*in2.' + data);
end
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!