Python How to combine integration equation in Python?

  • Thread starter Thread starter Nur Ziadah
  • Start date Start date
  • Tags Tags
    Integration Python
Click For Summary
The discussion focuses on calculating the key rate (R^Rate-wise) by integrating the function R(eta) over the range of eta from 0 to 1, using a log-normal probability distribution. The log-normal distribution is defined mathematically, and Python code is provided to visualize this distribution. Additionally, the code for R(eta) is shared, which involves calculating the Quantum Bit Error Rate (QBER) and entropy (H2) to derive the rate (Rsp). The main inquiry is about how to perform the integration of R(eta) over eta from 0 to 1, with a reference to using SciPy for numerical integration in Python. The user seeks guidance on defining the integrand function for this purpose, aiming to produce a specific output figure for R^Rate-wise.
Nur Ziadah
Messages
34
Reaction score
3
TL;DR
I'm calculating key rate (R^Rate-wise) by integrating R(eta) over all possible eta from 0 to 1, with a probability distribution (PDTC) which is a log-normal distribution using Python language.
I'm calculating key rate (R^Rate-wise) by integrating R(eta) over all possible eta from 0 to 1, with a probability distribution (PDTC) which is a log-normal distribution.

The equation of log-normal distribution:
243810


The equation of R(eta):
243811


Therefore, R^Rate-wise = Integrate_0^1(R(eta)*P(eta)*d eta):
243812


This is Python code of log-normal distribution:
Python:
x=np.linspace(0,1,1000)
sigma0=[0.9]
color=['green']
for i in range(len(sigma0)):
    sigma=sigma0[i]
    y=1/(x*sigma*np.sqrt(2*np.pi))*np.exp(-(np.log(x/0.3)+(1/2*sigma*sigma))**2/(2*sigma*sigma))
    plt.plot(x,y,color[i])
plt.title('Lognormal distribution')
plt.xlabel('x')
plt.ylabel('lognormal density distribution')
#plt.xlim((0,0.002))
plt.ylim((0,5))
plt.show()

This is Python code of R(eta):
Python:
n1=np.arange(10, 55, 1)
n=10**(-n1/10)Y0=1*(10**-5)
nd=0.25
ed=0.03
nsys=nd*n
QBER=((1/2*Y0)+(ed*nsys))/(Y0+nsys)
H2=-QBER*np.log2(QBER)-(1-QBER)*np.log2(1-QBER)
Rsp=np.log10((Y0+nsys)*(1-(2*H2)))
print (Rsp)

plt.plot(n1,Rsp)
plt.xlabel('Loss (dB)')
plt.ylabel('log10(Rate)')
plt.show()

My question is how to integrate R(eta) over possible eta from 0 to 1? The output should be in the following figure (R^Rate-wise):

243813


The referred article can be find in this link: https://arxiv.org/pdf/1712.08949.pdf

Thank you so much.
 
Technology news on Phys.org
I usually use the https://docs.scipy.org/doc/scipy/reference/tutorial/integrate.html to do numerical integration in Python. You will need to define a function which defines the integrand.
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 21 ·
Replies
21
Views
5K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 4 ·
Replies
4
Views
6K
Replies
4
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K