forked from ruogufang/pct
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_bcsvd_delay.m
63 lines (46 loc) · 1.18 KB
/
test_bcsvd_delay.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
% Generate Ca and R. Compute c from Ca and R.
% Set \Delta t and F_t to 1 for simplicity.
% Bolus delay d_t = 1 s
% Ground truth Ca
Ca = [1 0 0 0;
2 1 0 0;
0 2 1 0
0 0 2 1];
% delayed Ca
Cad = [0 0 0 0;
1 0 0 0;
2 1 0 0
0 2 1 0];
R = [1, 0.5 0 0]'; % This is our ground-truth R
% Normalize R to 1
% R = R / sum(R);
% Compute c from Ca and R
c = Ca * R;
% Estimate R by regular SVD
[U, S, V] = svd(Cad);
r_est1 = V * pinv(S) * U' * c;
% Zero-pad Ca and c
Cap = [0 0 0 0 0 0 2 1;
1 0 0 0 0 0 0 2;
2 1 0 0 0 0 0 0;
0 2 1 0 0 0 0 0;
0 0 2 1 0 0 0 0;
0 0 0 2 1 0 0 0
0 0 0 0 2 1 0 0
0 0 0 0 0 2 1 0];
cp = [c; zeros(length(c), 1)];
% Re-estimate R with
[Up, Sp, Vp] = svd(Cap);
r_est2 = Vp * pinv(Sp) * Up' * cp;
% Print results to screen
disp('Ground truth R:')
disp(R')
disp('SVD-estimated R:')
disp(r_est1')
disp('Block-circulant SVD-estimated R:')
disp(r_est2')
disp('As you can see, R(N+1:L) is non-zero.')
disp('But I think one should discard the R(N+1:L) anyway.')
% In this case, the block-circulant SVD gives
% a worse result, since c is a noise-free
% convolution of