-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds functions for calculating the total photon distribution of k lossy squeezed states #230
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure where to find the characteristic function
in the paper (if it's there), so I wasn't able to check whether it was written down correctly. Other than that, it looks great! 💯
thewalrus/quantum/fock_tensors.py
Outdated
@@ -608,7 +608,7 @@ def tvd_cutoff_bounds(mu, cov, cutoff, hbar=2, check_is_valid_cov=True, rtol=1e- | |||
and the user provided cutoff. | |||
|
|||
For the derivation see Appendix B of `'Exact simulation of Gaussian boson sampling in polynomial space and exponential time', | |||
Quesada and Arrazola et al. <10.1103/PhysRevResearch.2.023005>`_. | |||
Quesada and Arrazola <10.1103/PhysRevResearch.2.023005>`_. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't the full URL be needed here for the link to work? Although this function doesn't seem to be rendered in the docs at all. 🤔
Quesada and Arrazola <10.1103/PhysRevResearch.2.023005>`_. | |
Quesada and Arrazola <https://journals.aps.org/prresearch/abstract/10.1103/PhysRevResearch.2.023005>`_. |
|
||
def total_photon_number_distribution(n, k, s, eta, pref=1.0): | ||
r"""Probability of observing a total of :math:`n` photons when :math:`k` identical | ||
single-mode squeezed vacua with squeezing parameter s undergo loss by transmission :math:`\eta`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've actually never seen the word "vacua" before. 😄
single-mode squeezed vacua with squeezing parameter s undergo loss by transmission :math:`\eta`. | |
single-mode squeezed vacua with squeezing parameter ``s`` undergo loss by transmission :math:`\eta`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or actually change this to use :math:s
as below. Same below for my n
to :math:n
suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thewalrus/tests/test_quantum.py
Outdated
"""Test that the total photon number distribution has the correct mean and variance""" | ||
expectation_n = characteristic_function(s = s, k = k, eta = eta, poly_corr=1, mu = 0) | ||
expectation_n2 = characteristic_function(s = s, k = k, eta = eta, poly_corr=2, mu = 0) | ||
var_n =expectation_n2 - expectation_n ** 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var_n =expectation_n2 - expectation_n ** 2 | |
var_n = expectation_n2 - expectation_n ** 2 | |
thewalrus/tests/test_quantum.py
Outdated
expectation_n = characteristic_function(s = s, k = k, eta = eta, poly_corr=1, mu = 0) | ||
expectation_n2 = characteristic_function(s = s, k = k, eta = eta, poly_corr=2, mu = 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expectation_n = characteristic_function(s = s, k = k, eta = eta, poly_corr=1, mu = 0) | |
expectation_n2 = characteristic_function(s = s, k = k, eta = eta, poly_corr=2, mu = 0) | |
expectation_n = characteristic_function(s=s, k=k, eta=eta, poly_corr=1, mu=0) | |
expectation_n2 = characteristic_function(s=s, k=k, eta=eta, poly_corr=2, mu=0) |
thewalrus/tests/test_quantum.py
Outdated
@pytest.mark.parametrize("k", [4, 6, 10, 12]) | ||
@pytest.mark.parametrize("eta", [0, 0.1, 0.5, 1]) | ||
def test_characteristic_function_is_normalized(s, k, eta): | ||
r"""Check that when evaluated at \mu=1 the characteristic function gives 1""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r"""Check that when evaluated at \mu=1 the characteristic function gives 1""" | |
r"""Check that when evaluated at mu=1 the characteristic function gives 1""" | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me like this function evaluates at mu=0 rather than mu=1 as is stated here. Typo? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
thewalrus/tests/test_quantum.py
Outdated
# Note that s must be less than np.arctanh(np.sqrt(0.5)) ~= 0.88 | ||
p = np.tanh(s)**2 | ||
val = characteristic_function(k=k, s=s, eta=1.0, mu=mu) | ||
expected = ((1-p)/(1-2*p))**(k/2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected = ((1-p)/(1-2*p))**(k/2) | |
expected = ((1 - p) / (1 - 2 * p)) ** (k / 2) | |
thewalrus/tests/test_quantum.py
Outdated
@pytest.mark.parametrize("k", [4, 6, 10, 12]) | ||
def test_charactetistic_function_no_loss(s, k): | ||
"""Check the values of the characteristic function when there is no loss""" | ||
mu = mu = 0.5*np.log(2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mu = mu = 0.5*np.log(2) | |
mu = 0.5 * np.log(2) | |
yeah, not sure about the complex code in |
Co-authored-by: Theodor <theodor@xanadu.ai>
Co-authored-by: Theodor <theodor@xanadu.ai>
Codecov Report
@@ Coverage Diff @@
## master #230 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 21 21
Lines 1200 1228 +28
=========================================
+ Hits 1200 1228 +28
Continue to review full report at Codecov.
|
This PR implements the results in Appendix 5 and Eqs. 8 and 9 of https://arxiv.org/pdf/2102.12474.pdf