-
Notifications
You must be signed in to change notification settings - Fork 0
/
Generate_Kernels.m
56 lines (48 loc) · 1.16 KB
/
Generate_Kernels.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
function [ K, Q ] = Generate_Kernels( n, measure_variance, iterative_variance, percent_mass )
%%gernerates transition kernels OB and TK
x = [-1/n:-1/n:(1-n)/n];
p = 2*normcdf(x,0,iterative_variance);
Q = zeros(n,n);
K = zeros(n,n,n);
K(1,1,1) = 1;
for i=2:n
for j=2:n
if j==i
K(i,j,1) = 1 - p(1);
end
if j<i
K(i,j,1) = p(i-j)-p(i-j+1);
end
end
K(i,1,1) = p(i-1);
end
p = normcdf(x,0,measure_variance);
Q(1,1) = 1 - sum(p)/2;
Q(n,n) = 1 - sum(p)/2;
Q(1,n) = p(n-1)/2;
Q(n,1) = Q(1,n);
for i=2:n-1
for j=2:n-1
if j==i
Q(i,j) = 1 - p(1);
end
if j~=i
Q(i,j) = (p(abs(i-j))-p(abs(i-j)+1))/2;
end
Q(1,j) = p(j-1)/2;
Q(n,j) = p(n-j)/2;
end
Q(i,n) = p(n-i)/2;
Q(i,1) = p(i-1)/2;
end
for i=1:n-1
for k=1:n
K(k,1,i+1) = (1-percent_mass)*K(k,1,i);
for j=2:n-1
K(k,j,i+1) = (1-percent_mass)*K(k,j,i);
K(k,j,i+1) = K(k,j,i+1)+(percent_mass)*K(k,j-1,i);
end
K(k,n,i+1) = K(k,n,i)+((percent_mass)*K(k,n-1,i));
end
end
end