-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeterministicSel_tb
54 lines (42 loc) · 1.97 KB
/
deterministicSel_tb
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
49
50
51
52
53
54
import os
import numpy as np
import matplotlib.pyplot as plt
import inputGen
import weightGen
import test
"""generate input"""
power = 5
num, times = 2**power, 100
para = [-1, 1]
samples = inputGen.uniform(para, num, times)
"""generate weight"""
weight = weightGen.lowPassFir(0.2, 31)
"""test effect of sc's length on the precision of filter"""
minLen = 8
maxLen = 20
"""lfsr as RNS"""
CWALfsrError = test.Test_DeterministicSel('CWA', minLen, maxLen, 'lfsr', samples, weight)
HWALfsrError = test.Test_DeterministicSel('HWA', minLen, maxLen, 'lfsr', samples, weight)
"""halton as RNS"""
CWAHaltonError = test.Test_DeterministicSel('CWA', minLen, maxLen, 'halton', samples, weight)
HWAHaltonError = test.Test_DeterministicSel('HWA', minLen, maxLen, 'halton', samples, weight)
"""plot result"""
fig, (plot1, plot2) = plt.subplots(2,1, figsize=(8, 6))
xaxis = list(range(minLen, maxLen+1))
plot1.plot(xaxis, CWALfsrError, 'b-o', linewidth = 3, label='CWA')
plot1.plot(xaxis, HWALfsrError, 'g-o', linewidth = 3, label='HWA')
for i in range(len(xaxis)):
plot1.text(xaxis[i], CWALfsrError[i], str(round(CWALfsrError[i], 5)))
plot1.text(xaxis[i], HWALfsrError[i], str(round(HWALfsrError[i], 5)))
plot1.set_title('RMSE of different implementation of SC FIR flter changes against SC length with deterministic selection signal(lfsr)', fontsize=20)
plot1.legend(fontsize=14)
plot1.tick_params(axis='both', which='major', labelsize=14)
plot2.plot(xaxis, CWAHaltonError, 'b-o', linewidth = 3, label='CWA')
plot2.plot(xaxis, HWAHaltonError, 'g-o', linewidth = 3, label='HWA')
for i in range(len(xaxis)):
plot2.text(xaxis[i], CWAHaltonError[i], str(round(CWAHaltonError[i], 5)))
plot2.text(xaxis[i], HWAHaltonError[i], str(round(HWAHaltonError[i], 5)))
plot2.set_title('RMSE of different implementation of SC FIR flter changes against SC length with deterministic selection signal(halton)', fontsize=20)
plot2.legend(fontsize=14)
plot2.tick_params(axis='both', which='major', labelsize=14)
plt.show()