-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path16QAM_4QAM.py
More file actions
49 lines (42 loc) · 1.36 KB
/
16QAM_4QAM.py
File metadata and controls
49 lines (42 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import numpy as np
import math as math
import matplotlib.pyplot as plt
from SphereDecodingAlgo import *
pltx = []
plty16 = [0]*(19)
plty4 = [0]*(19)
SNRdB = 20
SNR = math.pow(10,SNRdB/10)
for step in range(2,21):
pltx.append(step)
for go in range(100):
cnt = 0
for step in range(2,21):
m = step ##transmiter
n = step ##reciver n >= m
variance = (m) / (SNR) ## varianc
# ###random sample
H = np.random.normal(0,1,(n,m))
flopsCount , ans, answer = sphereDecoding(m,n,H,variance,[],[],4)
print ("************ for 16QAM ***************")
print("flops: ",step,flopsCount)
print(ans)
print(answer.T)
plty16[cnt] += math.log(flopsCount,m)/100
print("*********** Now for 4QAM **************")
flopsCount , ans, answer = sphereDecoding(m,n,H,variance,[],[],2)
print("flops: ",step,flopsCount)
print(ans)
print(answer.T)
plty4[cnt] += math.log(flopsCount,m)/100
cnt = cnt + 1
####Plot the number of Flops
plt.plot(pltx, plty4,label = "4QAM")
plt.plot(pltx, plty16,'r--',label = "16QAM")
plt.legend()
plt.xlim(2, 20)
plt.xlabel('m')
plt.ylabel('ec = Log(Number of operation)')
plt.title('Differnet between 16QAM and 4QAM in 20db')
plt.show()
###Plot different bitween Babai radius estimation and algorithm radius estimation