How to plot integration equation using Python?












1














I have a few of integration equations and need to convert it into Python. The problem is when I tried to plot a graph according to the equation, some of the plot is not same with the original one.



The first equation is the error probability of authentication in normal operation:
enter image description here



The second equation is the error probability of authentication under MIM attack:



enter image description here



The error probability can be calculated by:



enter image description here



It is noted that:
enter image description here



Supposedly, the graph (original) will be shown like this:



enter image description here



Pe^normal = blue lines



Pe^MIM = red lines



Differences between two error probabilities = green lines



I tried to code it into Python and this is my full codes:



import matplotlib.pyplot as plt
import math
import numpy as np
from scipy.special import iv,modstruve

x=np.arange(0.1,21,1)
x = np.array(x)
t = 0.9
y = (np.exp(t*x/2)*(iv(0, t*x/2) - modstruve(0,t*x/2))-1)/(np.exp(t*x)-1)
z = (np.exp((1-t**2)*x/2)*(iv(0, (1-t**2)*x/2) - modstruve(0,(1-t**2)*x/2))-1)/(np.exp((1-t**2)*x)-1)
z2= y+z


plt.plot(x, y,'o', color='red',label='Normal')
plt.plot(x, z2, '-', color='black', label='MIM')
plt.plot(x, z, marker='s', linestyle='--', color='g', label='DIFF')
plt.xlabel('Mean photon number N')
plt.ylabel('Error probabiity')
plt.scatter(x,y)
plt.text(10, 0.4, 't=0.9', size=12, ha='center', va='center')
plt.ylim([0, 0.5])
plt.xlim([0, 20])
plt.legend()
plt.show()


The graph produce from the code is:
enter image description here



It looks like that my plot is not same with the original one in terms N=0 of Pe^MIM (red line) and differences between two error probabilities (green line).



I hope that anyone may help me to solve this problem.



Thank you.










share|improve this question
























  • Looks like a math issue. You did not show us a formula for P^{Auth, MIM}, also I note that you calculate the diff first and then get P^{Auth, MIM} from the diff. Is that a supposed method?
    – Konstantin Sekeresh
    Dec 28 '18 at 9:00










  • @ Konstantin Sekeresh. P^{Auth, MIM} was not given in this calculation. For the diff, I just try & error to calculate it using the P^{Auth, MIM}, and I know maybe my calculation is wrong. Thus, I need clarification from others about this calculation.
    – Afir
    Dec 28 '18 at 13:34










  • @ Konstantin Sekeresh.It can be noted that the difference is P^{Auth, MIM}- P^{Auth, normal}.
    – Afir
    Dec 29 '18 at 4:38
















1














I have a few of integration equations and need to convert it into Python. The problem is when I tried to plot a graph according to the equation, some of the plot is not same with the original one.



The first equation is the error probability of authentication in normal operation:
enter image description here



The second equation is the error probability of authentication under MIM attack:



enter image description here



The error probability can be calculated by:



enter image description here



It is noted that:
enter image description here



Supposedly, the graph (original) will be shown like this:



enter image description here



Pe^normal = blue lines



Pe^MIM = red lines



Differences between two error probabilities = green lines



I tried to code it into Python and this is my full codes:



import matplotlib.pyplot as plt
import math
import numpy as np
from scipy.special import iv,modstruve

x=np.arange(0.1,21,1)
x = np.array(x)
t = 0.9
y = (np.exp(t*x/2)*(iv(0, t*x/2) - modstruve(0,t*x/2))-1)/(np.exp(t*x)-1)
z = (np.exp((1-t**2)*x/2)*(iv(0, (1-t**2)*x/2) - modstruve(0,(1-t**2)*x/2))-1)/(np.exp((1-t**2)*x)-1)
z2= y+z


plt.plot(x, y,'o', color='red',label='Normal')
plt.plot(x, z2, '-', color='black', label='MIM')
plt.plot(x, z, marker='s', linestyle='--', color='g', label='DIFF')
plt.xlabel('Mean photon number N')
plt.ylabel('Error probabiity')
plt.scatter(x,y)
plt.text(10, 0.4, 't=0.9', size=12, ha='center', va='center')
plt.ylim([0, 0.5])
plt.xlim([0, 20])
plt.legend()
plt.show()


The graph produce from the code is:
enter image description here



It looks like that my plot is not same with the original one in terms N=0 of Pe^MIM (red line) and differences between two error probabilities (green line).



I hope that anyone may help me to solve this problem.



Thank you.










share|improve this question
























  • Looks like a math issue. You did not show us a formula for P^{Auth, MIM}, also I note that you calculate the diff first and then get P^{Auth, MIM} from the diff. Is that a supposed method?
    – Konstantin Sekeresh
    Dec 28 '18 at 9:00










  • @ Konstantin Sekeresh. P^{Auth, MIM} was not given in this calculation. For the diff, I just try & error to calculate it using the P^{Auth, MIM}, and I know maybe my calculation is wrong. Thus, I need clarification from others about this calculation.
    – Afir
    Dec 28 '18 at 13:34










  • @ Konstantin Sekeresh.It can be noted that the difference is P^{Auth, MIM}- P^{Auth, normal}.
    – Afir
    Dec 29 '18 at 4:38














1












1








1


1





I have a few of integration equations and need to convert it into Python. The problem is when I tried to plot a graph according to the equation, some of the plot is not same with the original one.



The first equation is the error probability of authentication in normal operation:
enter image description here



The second equation is the error probability of authentication under MIM attack:



enter image description here



The error probability can be calculated by:



enter image description here



It is noted that:
enter image description here



Supposedly, the graph (original) will be shown like this:



enter image description here



Pe^normal = blue lines



Pe^MIM = red lines



Differences between two error probabilities = green lines



I tried to code it into Python and this is my full codes:



import matplotlib.pyplot as plt
import math
import numpy as np
from scipy.special import iv,modstruve

x=np.arange(0.1,21,1)
x = np.array(x)
t = 0.9
y = (np.exp(t*x/2)*(iv(0, t*x/2) - modstruve(0,t*x/2))-1)/(np.exp(t*x)-1)
z = (np.exp((1-t**2)*x/2)*(iv(0, (1-t**2)*x/2) - modstruve(0,(1-t**2)*x/2))-1)/(np.exp((1-t**2)*x)-1)
z2= y+z


plt.plot(x, y,'o', color='red',label='Normal')
plt.plot(x, z2, '-', color='black', label='MIM')
plt.plot(x, z, marker='s', linestyle='--', color='g', label='DIFF')
plt.xlabel('Mean photon number N')
plt.ylabel('Error probabiity')
plt.scatter(x,y)
plt.text(10, 0.4, 't=0.9', size=12, ha='center', va='center')
plt.ylim([0, 0.5])
plt.xlim([0, 20])
plt.legend()
plt.show()


The graph produce from the code is:
enter image description here



It looks like that my plot is not same with the original one in terms N=0 of Pe^MIM (red line) and differences between two error probabilities (green line).



I hope that anyone may help me to solve this problem.



Thank you.










share|improve this question















I have a few of integration equations and need to convert it into Python. The problem is when I tried to plot a graph according to the equation, some of the plot is not same with the original one.



The first equation is the error probability of authentication in normal operation:
enter image description here



The second equation is the error probability of authentication under MIM attack:



enter image description here



The error probability can be calculated by:



enter image description here



It is noted that:
enter image description here



Supposedly, the graph (original) will be shown like this:



enter image description here



Pe^normal = blue lines



Pe^MIM = red lines



Differences between two error probabilities = green lines



I tried to code it into Python and this is my full codes:



import matplotlib.pyplot as plt
import math
import numpy as np
from scipy.special import iv,modstruve

x=np.arange(0.1,21,1)
x = np.array(x)
t = 0.9
y = (np.exp(t*x/2)*(iv(0, t*x/2) - modstruve(0,t*x/2))-1)/(np.exp(t*x)-1)
z = (np.exp((1-t**2)*x/2)*(iv(0, (1-t**2)*x/2) - modstruve(0,(1-t**2)*x/2))-1)/(np.exp((1-t**2)*x)-1)
z2= y+z


plt.plot(x, y,'o', color='red',label='Normal')
plt.plot(x, z2, '-', color='black', label='MIM')
plt.plot(x, z, marker='s', linestyle='--', color='g', label='DIFF')
plt.xlabel('Mean photon number N')
plt.ylabel('Error probabiity')
plt.scatter(x,y)
plt.text(10, 0.4, 't=0.9', size=12, ha='center', va='center')
plt.ylim([0, 0.5])
plt.xlim([0, 20])
plt.legend()
plt.show()


The graph produce from the code is:
enter image description here



It looks like that my plot is not same with the original one in terms N=0 of Pe^MIM (red line) and differences between two error probabilities (green line).



I hope that anyone may help me to solve this problem.



Thank you.







python integral






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 29 '18 at 4:40







Afir

















asked Dec 28 '18 at 8:34









Afir Afir

10611




10611












  • Looks like a math issue. You did not show us a formula for P^{Auth, MIM}, also I note that you calculate the diff first and then get P^{Auth, MIM} from the diff. Is that a supposed method?
    – Konstantin Sekeresh
    Dec 28 '18 at 9:00










  • @ Konstantin Sekeresh. P^{Auth, MIM} was not given in this calculation. For the diff, I just try & error to calculate it using the P^{Auth, MIM}, and I know maybe my calculation is wrong. Thus, I need clarification from others about this calculation.
    – Afir
    Dec 28 '18 at 13:34










  • @ Konstantin Sekeresh.It can be noted that the difference is P^{Auth, MIM}- P^{Auth, normal}.
    – Afir
    Dec 29 '18 at 4:38


















  • Looks like a math issue. You did not show us a formula for P^{Auth, MIM}, also I note that you calculate the diff first and then get P^{Auth, MIM} from the diff. Is that a supposed method?
    – Konstantin Sekeresh
    Dec 28 '18 at 9:00










  • @ Konstantin Sekeresh. P^{Auth, MIM} was not given in this calculation. For the diff, I just try & error to calculate it using the P^{Auth, MIM}, and I know maybe my calculation is wrong. Thus, I need clarification from others about this calculation.
    – Afir
    Dec 28 '18 at 13:34










  • @ Konstantin Sekeresh.It can be noted that the difference is P^{Auth, MIM}- P^{Auth, normal}.
    – Afir
    Dec 29 '18 at 4:38
















Looks like a math issue. You did not show us a formula for P^{Auth, MIM}, also I note that you calculate the diff first and then get P^{Auth, MIM} from the diff. Is that a supposed method?
– Konstantin Sekeresh
Dec 28 '18 at 9:00




Looks like a math issue. You did not show us a formula for P^{Auth, MIM}, also I note that you calculate the diff first and then get P^{Auth, MIM} from the diff. Is that a supposed method?
– Konstantin Sekeresh
Dec 28 '18 at 9:00












@ Konstantin Sekeresh. P^{Auth, MIM} was not given in this calculation. For the diff, I just try & error to calculate it using the P^{Auth, MIM}, and I know maybe my calculation is wrong. Thus, I need clarification from others about this calculation.
– Afir
Dec 28 '18 at 13:34




@ Konstantin Sekeresh. P^{Auth, MIM} was not given in this calculation. For the diff, I just try & error to calculate it using the P^{Auth, MIM}, and I know maybe my calculation is wrong. Thus, I need clarification from others about this calculation.
– Afir
Dec 28 '18 at 13:34












@ Konstantin Sekeresh.It can be noted that the difference is P^{Auth, MIM}- P^{Auth, normal}.
– Afir
Dec 29 '18 at 4:38




@ Konstantin Sekeresh.It can be noted that the difference is P^{Auth, MIM}- P^{Auth, normal}.
– Afir
Dec 29 '18 at 4:38












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53955672%2fhow-to-plot-integration-equation-using-python%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53955672%2fhow-to-plot-integration-equation-using-python%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Mossoró

Monofisismo

Cannot access a disposed object : DataContext