コード例 #1
0
ファイル: PS3_tests.py プロジェクト: cookt/mit
def test_5():
    G = numpy.array([[1, 1, 1,1], [1, 0, 1,1], [0, 1, 1,1]])
    print "Testing hard-decision decoding with no errors, G =", str(G.tolist())
    for i in range(100):
        message = numpy.random.random_integers(0, 1, 10)
        voltages = viterbi.convolutional_encode(message, G)
        decoded_message = decode(voltages, G)
        test_equality(message, decoded_message, voltages)
コード例 #2
0
ファイル: PS3_tests.py プロジェクト: cookt/mit
def test_3():
    G = numpy.array([[1, 1, 1], [1, 1, 0]])
    print "Testing hard-decision decoding with errors, G =", str(G.tolist())
    for i in range(100):
        message = numpy.random.random_integers(0, 1, 10)
        voltages = viterbi.convolutional_encode(message, G)
        # Make sure the errors are spaced far apart, and not too close
        # to the end of the message.
        err1 = random.randint(0, 4)
        err2 = random.randint(11, 15)
        voltages[err1] = 1 - voltages[err1]
        voltages[err2] = 1 - voltages[err2]
        decoded_message = decode(voltages, G)
        test_equality(message, decoded_message, voltages)