-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstat_variable_length.m
More file actions
89 lines (71 loc) · 2.43 KB
/
stat_variable_length.m
File metadata and controls
89 lines (71 loc) · 2.43 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
function stat_variable_length
load corruptedSeq;
intCorruptedSeq = arrayfun(@(x) symbol_to_int(x), corruptedSeq);
load Q;
load testSeq;
pi_0 = load('pinit.mat');
pi_0 = pi_0.pinit;
tabLength = [10 100 500 750 1000 1300];
start_state = 1:40;
func = 'random_flip';
limitConvergeance = 20000;
convergeance = 100;
nbLoop = 20;
fileID = fopen('stat_length.txt', 'w');
for length = tabLength
length
fprintf(fileID, 'length = %d \n', length);
nbIter = 0;
nbConverge = 0;
nbDecodeConv = 0;
nbDecodeNotConv = 0;
for i = 1:nbLoop
i
[nbIterations, mar_chaine] = Metro_Hast_no_print(intCorruptedSeq(1:length), Q, pi_0, start_state, func, convergeance, limitConvergeance);
result = mar_chaine(end, :);
decoded = decode(intCorruptedSeq(1:length), result);
seq = arrayfun(@(x) int_to_symbol(x), decoded)
if(length < 18)
testLength = length
else
testLength = 18;
end
if (nbIterations < limitConvergeance)
nbIter = nbIter + nbIterations;
nbConverge = nbConverge + 1;
if(strcmp(seq(1:testLength), testSeq(1:testLength)))
nbDecodeConv = nbDecodeConv + 1;
end
else
if(strcmp(seq(1:testLength), testSeq(1:testLength)))
nbDecodeNotConv = nbDecodeNotConv + 1;
end
end
end
if (nbConverge ~= 0)
meanIter = nbIter/nbConverge;
fprintf(fileID, 'Moyenne iterations = %d \n', meanIter);
else
fprintf(fileID, 'Never converge \n');
end
pourcConverge = (nbConverge/nbLoop)*100;
fprintf(fileID, 'pourcentage de convergeance = %d \n', pourcConverge);
if (nbConverge ~= 0)
pourcDecodeConv = (nbDecodeConv/nbConverge)*100;
fprintf(fileID, 'pourcentage de correct avec convergeance = %d \n', pourcDecodeConv);
else
fprintf(fileID, 'Never converge \n');
end
nbNotConverge = nbLoop - nbConverge;
if (nbNotConverge ~= 0)
pourcDecodeNotConv = (nbDecodeNotConv/nbNotConverge)*100;
fprintf(fileID, 'pourcentage de correct sans convergeance = %d \n', pourcDecodeNotConv);
else
fprintf(fileID, 'Always converge \n');
end
nbDecode = nbDecodeConv + nbDecodeNotConv;
pourcDecode = (nbDecode/nbLoop)*100;
fprintf(fileID, 'pourcentage de correct = %d \n', pourcDecode);
end
fclose(fileID);
end