hichamjanati / pyldpc

Creation of LDPC codes & simulation of coding and decoding binary data. Applications to sound and image files.
BSD 3-Clause "New" or "Revised" License
119 stars 32 forks source link

Unable to decode message even with just 1 bit flip in encoded msg #25

Closed aditi741997 closed 2 years ago

aditi741997 commented 2 years ago

Hello

I am using dv = 4, dc = 5, n = 20, which gives k = 7. I generate a message of length 7, encode them using ldpc encode, with snr=100000 [since I don't want to add noise]. I then simulate errors in communication by randomly flipping 1 bit of the encoded message. But, I am unable to decode this message correctly!

Here's the code: `seed = np.random.RandomState(42)

H, G = make_ldpc(n, d_v, d_c, systematic=True, sparse=True)

input_msg = np.random.randint(2, size=k)

enc_msg = encode(G, input_msg, snr, seed=seed)

dec_msg = get_message(G, decode(H, enc_msg, snr)) # works correctly

flip_ind = np.random.randint(0, len(enc_msg) - 1 )

enc_msg[flip_ind] = -1.0 * enc_msg[flip_ind] # change 1 to -1 and vice versa, to simulate bit flip due to communication errors

flipped_dec_msg = get_message(G, decode(H, enc_msg, snr)) # this is wrong `

xingbod commented 2 years ago

Hi Aditi, have you solve the problem? I have same issues on bit flipping

hichamjanati commented 2 years ago

in pyldpc, decoding only assumes additive white Gaussian noise with some specified SNR, bit flip errors aren't supported for now