LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
matlab
lib
m3a
m3a
mtrace
mtrace_bootstrap.m
1
function ci = mtrace_bootstrap(T,A,resamples)
2
3
if
nargin == 2
4
resamples = 1000;
5
end
6
7
% number of samples
8
N = length(T);
9
% target block length
10
BL = 50;
11
% number of blocks
12
BN = floor(N / BL);
13
R = mod(N, BN);
14
% actual block lengths
15
L = ones(BN,1) * floor(N / BN);
16
L(1:R) = L(1:R) + 1;
17
% block indices
18
I = (1:BN)
';
19
% compute confidence intervals
20
statfunc = @(idx) bf(idx);
21
ci = bootci(resamples, statfunc, I);
22
23
24
function STATS = bf(idx)
25
[t,a] = blocks(T,A,idx,L);
26
p = mtrace_pc(t,a);
27
B = mtrace_moment(t,a,1,0,1);
28
F = mtrace_moment(t,a,1,1,1);
29
S = mtrace_sigma(t, a);
30
STATS = [p'
, B
', F'
, S(:)
'];
31
end
32
33
function [t,a] = blocks(T,A,idx,L)
34
n = sum(L(idx));
35
t = zeros(n,1);
36
a = zeros(n,1);
37
last = cumsum(L);
38
first = last - L + 1;
39
next = 1;
40
for i = 1:length(idx)
41
j = idx(i);
42
d1 = next;
43
d2 = next + L(j) - 1;
44
s1 = first(j);
45
s2 = last(j);
46
t(d1:d2) = T(s1:s2);
47
a(d1:d2) = A(s1:s2);
48
next = d2 + 1;
49
end
50
end
51
52
end
Generated by
1.9.8