col_w = 3
row_w = 6
N=1200
numIter = 20
noiseDensity = .058

######################################################################
#
# You probably should not need to change anything below this point.
#
######################################################################

K=N*col_w/row_w
E=(N-K)*row_w
L=CodeMaker.make_H_gallager(N,col_w,row_w)

code = pycodes.pyLDPC.LDPCCode(N,K,E,L)

c = [0]*N
ev = channels.BSCOutput(c,noiseDensity)
code.setevidence(ev,alg='default')

for i in range(numIter):
    code.decode()

beliefs = code.getbeliefs()

bitDiffs = reduce(lambda x,y: x+y,map(lambda z: z > 0.5,beliefs))

print `bitDiffs` + ' bits wrong after ' + `numIter` + ' iterations.'
示例#2
0
N=[120,1200, 12000, 120000]

col_w = [3]*len(N)
row_w = [6]*len(N)

leftDegrees = {2:0.33241, 3:.24632, 4:.11014, 6:0.31112}
rightDegrees = {6:.76611, 7:.23389}

# the following degree distribution is from Luby, Mitzenmacher et al. ISIT '98
# it doesn't seem to work...
#leftDegrees = {3:.44506, 5:.26704, 9:0.14835, 17:.07854, 33:0.04046,65:0.02055}
#rightDegrees = {7:.35282,8:.29548,19:.10225, 20:0.18321,84:0.04179,85:0.02445}

K=map(lambda n,c,r: n*c/r,N,col_w,row_w)

L_r=map(lambda n,c,r: CodeMaker.make_H_gallager(n,c,r),N,col_w,row_w)
E_r=map(lambda n,k,r: (n-k)*r,N,K,row_w)
L_i=map(lambda n,k: CodeMaker.MakeIrregularLDPCCodeFromLambdaRho
        (n,k,leftDegrees,rightDegrees),N,K)

def CountEdges(linkArray):
    return reduce(lambda x,y: x+y, map(len,linkArray))
E_i=map(CountEdges,L_i)

numSteps = [10]*len(N)

numToErase = map(lambda n,k,ns:
                 range(round((n-k)*1.025),round(k*1.175),round(.15*k/ns)),
                 N,K,numSteps)
numTimes = map(lambda x: [250]*len(x),numToErase)

"""
This module contains various regression tests designed to make sure
channel decoding functions are working correctly.
"""

import pycodes
from pycodes.utils import channels, CodeMaker, testing
from math import exp

(N,K) = (1200,600)
L = CodeMaker.make_H_gallager(N,3,6) 
E = (N-K)*6 # number of edges in the code graph

testing.RequireSuccessfulDecoding(
    'Small BEC test decoded with SumProductBP',
    N,K,E,L,'erasures',0.35,channels.BECOutput,
    numTrials=50,maxIter=20,algorithm='SumProductBP',requiredSuccessRate=0.8)

testing.RequireSuccessfulDecoding(
    'Small BEC test decoded with LRSumProductBP',
    N,K,E,L,'erasures',0.35,
    lambda x,y: map(lambda z: exp(min(z,10)),channels.BECOutput(x,y)),
    numTrials=50,maxIter=20,algorithm='LRSumProductBP',
    requiredSuccessRate=0.8)
示例#4
0
import random
from pycodes.utils import CodeMaker
from pycodes.utils.channel_coding_perf import *
from pycodes.utils.channels import BSCOutput

seed = random.getstate()
random.setstate(seed)
print 'using seed', seed

col_w = 3
row_w = 6
N = 1002
K = N * col_w / row_w
E = (N - K) * row_w
L = CodeMaker.make_H_gallager(N, col_w, row_w)

noiseDensity = [0.08, 0.06, 0.04]
numTrials = [250] * len(noiseDensity)
maxIter = 20

tester = Tester([
    CodeParams(N,
               K,
               E,
               L,
               'small test',
               'bit flips',
               noiseDensity,
               BSCOutput,
               numTrials,
               maxIter,