예제 #1
0
''' 多组取平均 '''
gro_num = 100
mtype_num = len(mtype)
times = []
''' 采样 '''
rssi_A, rssi_B, rssi_E = sampling('RSSI', sampling_period, sampling_time, 0.9,
                                  0.4)
phase_A, phase_B, phase_E = mod(
    sampling('Phase', sampling_period, sampling_time, 0.9, 0.4), 2 * pi)
''' RSSI Only '''
begin = datetime.datetime.now()
for i in range(gro_num):
    print 'Running... Current group: RSSI Only, ', i
    bits_A_rssi, drop_list_A = quantization_thre(rssi_A, block_size, coef)
    bits_B_rssi, drop_list_B = quantization_thre(rssi_B, block_size, coef)
    bits_A_rssi = remain(bits_A_rssi, drop_list_A, drop_list_B)
    bits_B_rssi = remain(bits_B_rssi, drop_list_A, drop_list_B)
end = datetime.datetime.now()
times.append(end - begin)
''' Phase Only '''
begin = datetime.datetime.now()
for i in range(gro_num):
    print 'Running... Current group: Phase Only, ', i
    bits_A_phase = quantization_even('Phase', phase_A, size(phase_A), qtype,
                                     order)
    bits_B_phase = quantization_even('Phase', phase_B, size(phase_B), qtype,
                                     order)
end = datetime.datetime.now()
times.append(end - begin)
''' cross '''
begin = datetime.datetime.now()
예제 #2
0
coef = 0.8
''' 多组取平均 '''
group_num = 100
block_num = len(block_size)
bmr = zeros((group_num, block_num))
bgr = zeros((group_num, block_num))

for i in range(group_num):
    for j in range(block_num):
        print 'Running... Current group: ', i, j
        ''' 采样 '''
        rssi_A, rssi_B, rssi_E = sampling_RSSI(sampling_period, sampling_time)
        ''' RSSI量化 '''
        bits_A, drop_list_A = quantize_ASBG_1bit(rssi_A, block_size[j], coef)
        bits_B, drop_list_B = quantize_ASBG_1bit(rssi_B, block_size[j], coef)
        bits_A = remain(bits_A, drop_list_B)
        bits_B = remain(bits_B, drop_list_A)
        ''' 评价性能 '''
        bmr[i, j] = BMR(bits_A, bits_B)
        bgr[i, j] = BGR(bits_A, sampling_time, sampling_period)

bmr = mean(bmr, 0)
bgr = mean(bgr, 0)
''' 画图 '''
plt.figure(figsize=(8, 5))
plt.plot(block_size, bmr, 'ko-')
plt.xlabel('Block size')
plt.ylabel('BMR')
plt.title('BMR of different block sizes(coef=%.2f)' % coef)
plt.show()