-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgen_uec_transitions.m
68 lines (53 loc) · 1.85 KB
/
gen_uec_transitions.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
64
65
66
67
function [ transitions ] = gen_uec_transitions( C, Px_vector, len )
%GEN_UEC_TRANSITIONS Generates a Transitions X 5 matrix with the UEC
%transitions and the conditional transition probablity
% Detailed explanation goes here
r = 2*size(C,1);
% Determine number of codeword bits
n = size(C,2);
l=len;
transitions = zeros(2*r, n+3);
gammas = zeros(2*r, 1);
for mprime = 1:r
odd = mod(mprime,2);
for y = 0:1
% Set the from state
transitions(y*r+mprime,1) = mprime;
% Set the to state
if y == 0
m = 1 + odd;
else
m = min(mprime+2,r - odd);
end
transitions(y*r+mprime,2) = m;
% Set the uncoded bit
transitions(y*r+mprime,3) = y;
% Set the codeword
if y == odd
transitions(y*r+mprime,4:end) = ~C(ceil(mprime/2), :);
else
transitions(y*r+mprime,4:end) = C(ceil(mprime/2), :);
end
% See Eq (6) in Derivations for (Maunder et al., 2013)
if mprime <= r-2
if m == mprime + 2
Pmmprime = (1-sum(Px_vector(1:ceil(mprime/2))))/(1-sum(Px_vector(1:ceil(mprime/2)-1)));
elseif m == 1+odd
Pmmprime = Px_vector(ceil(mprime/2))/(1-sum(Px_vector(1:ceil(mprime/2)-1)));
else
Pmmprime = 0;
end
else
if m == 1 + odd
Pmmprime = (1-sum(Px_vector(1:r/2-1)))/(1+l-r/2-sum(Px_vector(1:r/2-1).*(1+(1:r/2-1)-r/2)));
elseif m == mprime
Pmmprime = (l-r/2-sum(Px_vector(1:r/2-1).*((1:r/2-1)-r/2)))/(1+l-r/2-sum(Px_vector(1:r/2-1).*(1+(1:r/2-1)-r/2)));
else
Pmmprime = 0;
end
end
gammas(y*r+mprime,:) = log(Pmmprime);
end
end
transitions = [transitions , gammas];
end