Renamed naive soft decision to maximum likelihood; Removed reference to R matrix

This commit is contained in:
Andreas Tsouchlos 2022-11-10 08:40:25 +01:00
parent 5865a8683f
commit f29c2e71de
4 changed files with 10 additions and 31 deletions

View File

@ -4,7 +4,7 @@ import itertools
# TODO: Unify the interface regarding [0, 1]^n and [-1, 1]^n
class SoftDecisionDecoder:
class MLDecoder:
"""This class naively implements a soft decision decoder. The decoder calculates
the correlation between the received signal and each codeword and then chooses the
one with the largest correlation.

View File

@ -8,8 +8,8 @@ import os
from itertools import chain
from timeit import default_timer
from decoders import proximal, naive_soft_decision
from utility import simulations, encoders, codes
from decoders import proximal, maximum_likelihood
from utility import simulations, codes
def test_decoders(G, decoders: typing.List) -> pd.DataFrame:
@ -27,7 +27,7 @@ def test_decoders(G, decoders: typing.List) -> pd.DataFrame:
decoder=decoder,
SNRs=SNRs,
target_bit_errors=100,
N_max=30000)
N_max=50000)
data[f"BER_{decoder_name}"] = BERs_sd
@ -91,10 +91,10 @@ def main():
H = codes.get_systematic_H(G)
decoders = {
"naive_soft_decision": naive_soft_decision.SoftDecisionDecoder(G, H),
"proximal_0_01": proximal.ProximalDecoder(H, K=100, gamma=0.01),
"proximal_0_05": proximal.ProximalDecoder(H, K=100, gamma=0.05),
"proximal_0_15": proximal.ProximalDecoder(H, K=100, gamma=0.15),
"naive_soft_decision": maximum_likelihood.MLDecoder(G, H),
"proximal_0_01": proximal.ProximalDecoder(H, gamma=0.01),
"proximal_0_05": proximal.ProximalDecoder(H, gamma=0.05),
"proximal_0_15": proximal.ProximalDecoder(H, gamma=0.15),
}
data = test_decoders(G, decoders)

View File

@ -1,6 +1,6 @@
import unittest
import numpy as np
from decoders import naive_soft_decision
from decoders import maximum_likelihood
class CodewordGenerationTestCase(unittest.TestCase):
@ -14,12 +14,8 @@ class CodewordGenerationTestCase(unittest.TestCase):
H = np.array([[1, 0, 1, 0, 1, 0, 1],
[0, 1, 1, 0, 0, 1, 1],
[0, 0, 0, 1, 1, 1, 1]])
R = np.array([[0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 0, 1]])
decoder = naive_soft_decision.SoftDecisionDecoder(G, H, R)
decoder = maximum_likelihood.MLDecoder(G, H)
expected_datawords = np.array([[0, 0, 0, 0],
[0, 0, 0, 1],

View File

@ -58,23 +58,6 @@ class CodesTestCase(unittest.TestCase):
self.assertEqual(np.array_equal(expected_H, H), True)
def test_get_systematic_R(self):
# Hamming(7,4) code
G = np.array([[1, 0, 0, 0, 0, 1, 1],
[0, 1, 0, 0, 1, 0, 1],
[0, 0, 1, 0, 1, 1, 0],
[0, 0, 0, 1, 1, 1, 1]])
expected_R = G = np.array([[1, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0]])
R = codes.get_systematic_R(G)
self.assertEqual(np.array_equal(expected_R, R), True)
if __name__ == '__main__':
unittest.main()