Made the way simulations are done and plotted more scalable
This commit is contained in:
parent
cc855b8941
commit
0ea297ad45
36
sw/main.py
36
sw/main.py
@ -21,30 +21,44 @@ def main():
|
|||||||
[0, 1, 1, 0, 0, 1, 1],
|
[0, 1, 1, 0, 0, 1, 1],
|
||||||
[0, 0, 0, 1, 1, 1, 1]])
|
[0, 0, 0, 1, 1, 1, 1]])
|
||||||
|
|
||||||
|
# Define encoder and decoders
|
||||||
|
|
||||||
encoder = channel.Encoder(G)
|
encoder = channel.Encoder(G)
|
||||||
|
|
||||||
proximal_decoder = proximal.ProximalDecoder(H, K=100, gamma=0.01)
|
decoders = {"naive_soft_decision": naive_soft_decision.SoftDecisionDecoder(G, H),
|
||||||
soft_decision_decoder = naive_soft_decision.SoftDecisionDecoder(G, H)
|
# "proximal": proximal.ProximalDecoder(H, K=100, gamma=0.01),
|
||||||
|
}
|
||||||
|
|
||||||
# Test decoder
|
# Test decoders
|
||||||
|
|
||||||
k, n = G.shape
|
k, n = G.shape
|
||||||
d = np.zeros(k) # All-zeros assumption
|
d = np.zeros(k) # All-zeros assumption
|
||||||
|
|
||||||
SNRs_sd, BERs_sd = utility.test_decoder(encoder=encoder,
|
SNRs = np.linspace(1, 7, 9)
|
||||||
decoder=soft_decision_decoder,
|
data = pd.DataFrame({"SNR": SNRs})
|
||||||
d=d,
|
|
||||||
SNRs=np.linspace(1, 7, 9),
|
|
||||||
target_bit_errors=500)
|
|
||||||
|
|
||||||
data = pd.DataFrame({"SNR": SNRs_sd, "BER_sd": BERs_sd})
|
for decoder_name in decoders:
|
||||||
|
decoder = decoders[decoder_name]
|
||||||
|
_, BERs_sd = utility.test_decoder(encoder=encoder,
|
||||||
|
decoder=decoder,
|
||||||
|
d=d,
|
||||||
|
SNRs=SNRs)
|
||||||
|
|
||||||
|
data[f"BER_{decoder_name}"] = BERs_sd
|
||||||
|
|
||||||
# Plot results
|
# Plot results
|
||||||
|
|
||||||
ax = sns.lineplot(data=data, x="SNR", y="BER_sd")
|
fig, axes = plt.subplots(1, 1)
|
||||||
|
fig.suptitle("Bit-Error-Rates of various decoders")
|
||||||
|
|
||||||
|
for decoder_name in decoders:
|
||||||
|
ax = sns.lineplot(data=data, x="SNR", y=f"BER_{decoder_name}", label=f"{decoder_name}")
|
||||||
|
|
||||||
|
ax.set_title("Hamming(7,4) Code")
|
||||||
ax.set(yscale="log")
|
ax.set(yscale="log")
|
||||||
ax.set_yticks([10e-5, 10e-4, 10e-3, 10e-2, 10e-1, 10e0])
|
ax.set_yticks([10e-5, 10e-4, 10e-3, 10e-2, 10e-1, 10e0])
|
||||||
# ax.set_ylim([10e-6, 10e0])
|
ax.legend()
|
||||||
|
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user