qutip / QuantumToolbox.jl

Quantum Toolbox in Julia
https://qutip.org/QuantumToolbox.jl/
BSD 3-Clause "New" or "Revised" License
46 stars 16 forks source link

Introduce `rand_ket` and generate `rand_dm` using Ginibre ensemble method #185

Closed ytdHuang closed 4 months ago

ytdHuang commented 4 months ago

This PR introduces rand_ket, and also modify the method for generating random density matrix rand_dm.

I think the current method for generating random density matrix is not random enough. Because the real value of off-diagonal elements are always positive.

Here, I implement the method to generate random density matrix from Ginibre ensemble, which is also the default method in qutip. I think this method is the more standard one in the literature.

Furthermore, with this method, we can specify the rank of the density matrix, i.e., the number of eigenvalues which are positive. The other eigenvalues will be very close to zero (< 1e-15).

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 93.36%. Comparing base (3a68599) to head (c22f230). Report is 2 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #185 +/- ## ========================================== + Coverage 93.33% 93.36% +0.03% ========================================== Files 28 28 Lines 2101 2111 +10 ========================================== + Hits 1961 1971 +10 Misses 140 140 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

ytdHuang commented 4 months ago

Is this method equal to the current one in the case rank =N?

Not equal, as I mentioned in above. I think the current method is not random enough.

albertomercurio commented 4 months ago

In the case rank = n the Ginibre generates a square complex random matrix and then multiplies it by its adjoint. Like the previous implementation, except for the randn instead of the rand function. It is just to understand. The implementation is good, aside from the two comments made above.