signal_power = mapper.get_signal_average_power() # what is the noise power and standard deviation when SNR is 10dB? noise_power = signal_power / 10.0 noise_std_dev = math.sqrt(noise_power) # initialize random number generator. this seed is fixed constant in order # to get deterministic results in this example. random.seed(314159265359) # add white gaussian noise at 10dB to signal print "Adding white gaussian noise at 10dB." noisy_symbols = [sym + random.gauss(0, noise_std_dev) for sym in symbols] # round to closest integer noisy_symbols = [int(x + 0.5) for x in noisy_symbols] print "noisy symbols:", noisy_symbols # instantiate decoder decoder = Decoder(k, B, d, map_func) # update decoder with gathered points for i in xrange(spine_length): decoder.advance([ noisy_symbols[i], noisy_symbols[i + spine_length], noisy_symbols[i + 2 * spine_length] ]) print "decoded hex:", decoder.get_most_likely().encode("hex") # make sure we got the message we started with assert (decoder.get_most_likely() == message)
# get average signal power signal_power = mapper.get_signal_average_power() # what is the noise power and standard deviation when SNR is 10dB? noise_power = signal_power / 10.0 noise_std_dev = math.sqrt(noise_power) # initialize random number generator. this seed is fixed constant in order # to get deterministic results in this example. random.seed(314159265359) # add white gaussian noise at 10dB to signal print "Adding white gaussian noise at 10dB." noisy_symbols = [sym + random.gauss(0, noise_std_dev) for sym in symbols] # round to closest integer noisy_symbols = [int(x + 0.5) for x in noisy_symbols] print "noisy symbols:", noisy_symbols # instantiate decoder decoder = Decoder(k, B, d, map_func) # update decoder with gathered points for i in xrange(spine_length): decoder.advance([noisy_symbols[i], noisy_symbols[i+spine_length], noisy_symbols[i+2*spine_length]]) print "decoded hex:", decoder.get_most_likely().encode("hex") # make sure we got the message we started with assert(decoder.get_most_likely() == message)
# print "Adding white gaussian noise at 10dB." # noisy_symbols = [sym + random.gauss(0, noise_std_dev) for sym in symbols] # # round to closest integer # noisy_symbols = [int(x + 0.5) for x in noisy_symbols] # print "noisy symbols:", noisy_symbols # [cgl] myself noise symbols. if the prr is low, while the number of errors in one packet is rare, then Spinal code can also achieve very good performance. noisy_symbols = [sym for sym in symbols] noisy_symbols[3] += 3 ###=============================================================================== # instantiate decoder decoder = Decoder(k, B, d, map_func) # update decoder with gathered points for i in xrange(spine_length): decodeAdv = [] for j in range(numPssMsg): decodeAdv.append(noisy_symbols[i + j * spine_length]) decoder.advance(decodeAdv) # decoder.advance([noisy_symbols[i], # noisy_symbols[i+spine_length]]) # decoder.advance([noisy_symbols[i], # noisy_symbols[i+spine_length], # noisy_symbols[i+2*spine_length]]) print "decoded hex:", decoder.get_most_likely().encode("hex") # make sure we got the message we started with assert (decoder.get_most_likely() == message)