I have several equations and need to convert it into Python. The problem is that I tried to plot a graph according to the equation. However, the graph that I get is not the same as the original one.
In the paper, the equation of error probability for MIM attack is given by:
First Image
Second Image
The equation to calculate the error probability of PNS attack is given by:
Where the region condition satisfied:
The error probability of PNS attack should be plotted like this:
My question: How to insert equation 8.1 into equation 8.5?
This is my python code according to equation 8.5:
import matplotlib.pyplot as plt
import math
import numpy as np
from scipy.special import iv,modstruve
x=[0, 5, 10, 15, 20]
t= 0.9
x = np.array(x)
y = (np.exp(x*t/2)*(iv(0, x*t/2) - modstruve(0,x*t/2))-1)/(np.exp(x*t/2-1))
plt.plot(x, y, label='Normal')
plt.xlabel('Mean photon number N')
plt.ylabel('Error probabiity')
plt.scatter(x,y)
plt.title('N/2')
plt.ylim([0, 0.5])
plt.legend()
plt.show()
Please help me regarding this matter.
Thank you.
I updated your code by computing y for N1 and for N2 with the formula given in the image. This give me y1 and y2 which I believe are the components of the drawn function f(y1,y2). Yet, without the rest of the paper I cannot figure out exactly what is drawn on the image you provided.
The following code generates an image quite similar with f : y1,y2 -> y1+y2
:
import matplotlib.pyplot as plt
import numpy as np
from scipy.special import iv, modstruve
x = range(0, 20, 1)
# t= 0.1
for t, color in zip([0.9, 0.1, 0.5], ['b', 'g', 'r']):
x1 = (1 - t) * np.array(x)
y1 = (np.exp(x1 / 2) * (iv(0, x1 / 2) - modstruve(0, x1 / 2)) - 1) / (np.exp(x1) - 1)
x2 = (1 - t) * t * np.array(x)
y2 = (np.exp(x2 / 2) * (iv(0, x2 / 2) - modstruve(0, x2 / 2)) - 1) / (np.exp(x2) - 1)
y = y1 + y2
plt.plot(x, y, label=t, color=color)
plt.scatter(x, y, color=color)
# N1 = N2
x1 = np.array(x) / 2
y1 = (np.exp(x1 / 2) * (iv(0, x1 / 2) - modstruve(0, x1 / 2)) - 1) / (np.exp(x1) - 1)
x2 = np.array(x) / 2
y2 = (np.exp(x2 / 2) * (iv(0, x2 / 2) - modstruve(0, x2 / 2)) - 1) / (np.exp(x2) - 1)
y = y1 + y2
plt.plot(x, y, label="N1=N2=N/2", color='k')
plt.scatter(x, y, color='k')
plt.xlabel('Mean photon number N')
plt.ylabel('Error probabiity')
plt.title('N/2')
plt.ylim([0, 0.35])
plt.legend()
plt.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With