QBism
python tools for the budding quantum bettabilitarian
Installation
pip install qbism
Note that qbism relies on qutip!
Usage
Let's start off with a random density matrix:
from qbism import *
import qutip as qt
import numpy as np
d = 2
rho = qt.rand_dm(d)
We construct a random Weyl-Heisenberg IC-POVM, and get the magical quantum coherence matrix. We find the probabilities with respect to this POVM.
povm = weyl_heisenberg_povm(qt.rand_ket(d))
phi = povm_phi(povm)
p = dm_probs(rho, povm)
print("probs: %s" % p)
probs: [0.20215649 0.20215649 0.29784351 0.29784351]
We can compare the classical probabilities (for a Von Neumann measurement after a POVM measurement whose outcome we are ignorant of) to the the quantum probabilities (in the case where we go directly to the Von Neumann measurement):
H = qt.rand_herm(d)
vn = [v*v.dag() for v in H.eigenstates()[1]]
classical_probs = conditional_probs(vn, povm) @ p
quantum_probs = conditional_probs(vn, povm) @ phi @ p
print("classsical probs: %s" % classical_probs)
print("quantum probs: %s" % quantum_probs)
post_povm_rho = sum([(e*rho).tr()*(e/e.tr()) for e in povm])
assert np.allclose(classical_probs, [(v*post_povm_rho).tr() for v in vn])
assert np.allclose(quantum_probs, [(v*rho).tr() for v in vn])
classsical probs: [0.55802905 0.44197095]
quantum probs: [0.65778315 0.34221685]
Now let's get a SIC-POVM and explore time evolution:
sic = sic_povm(d)
sic_phi = povm_phi(sic)
sic_p = dm_probs(rho, sic)
U = qt.rand_unitary(d)
evolved_sic = [U*e*U.dag() for e in sic]
R = conditional_probs(evolved_sic, sic).T
time_evolved_sic_p = R @ sic_phi @ sic_p
print("time evolved probs: %s" % time_evolved_sic_p)
assert np.allclose(dm_probs(U*rho*U.dag(), sic), time_evolved_sic_p)
time evolved probs: [0.20445193 0.20445193 0.29554807 0.29554807]
We could also use:
time_evolved_sic_p2 = povm_map([U], sic) @ sic_phi @ sic_p
assert np.allclose(time_evolved_sic_p, time_evolved_sic_p2)
Finally, let's check out partial traces:
entangled = qt.rand_dm(4)
entangled.dims = [[2,2],[2,2]]
povm2 = weyl_heisenberg_povm(qt.rand_ket(2))
povm4 = apply_dims(weyl_heisenberg_povm(qt.rand_ket(4)), [2,2])
phi = povm_phi(povm4)
p = dm_probs(entangled, povm4)
ptrA = povm_map(partial_trace_kraus(0, [2,2]), povm4, povm2)
ptrB = povm_map(partial_trace_kraus(1, [2,2]), povm4, povm2)
assert np.allclose(dm_probs(entangled.ptrace(0), povm2), ptrA @ phi @ p)
assert np.allclose(dm_probs(entangled.ptrace(1), povm2), ptrB @ phi @ p)
Check out the tutorial for the full story!
Thanks to nbdev!
Metadata
Release files for qbism 0.1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| qbism-0.1.0.6.tar.gz | 265.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| qbism-0.1.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 562.6 kB
Release files / qbism-0.1.0.6.tar.gz
| Download URL | qbism-0.1.0.6.tar.gz |
|---|---|
| Size | 265.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9644523863e9dbd780b08194f202249630acb8b0182855fe88764e0a599b84ae
|
|
BLAKE2b-256 checksum How to use checksums |
a82cc118419f01f746ea290d3769e574240b63b4c724f53e0979a00e20e13f2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
|
Release files / qbism-0.1.0.6-py3-none-any.whl
| Download URL | qbism-0.1.0.6-py3-none-any.whl |
|---|---|
| Size | 297.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cd3b37ca8874a0f23b8474b53f9378a5ea29551f75548841ba204c6655667c5b
|
|
BLAKE2b-256 checksum How to use checksums |
4094f3513ac9d0264c58e7fc33e86d9b306ffd288f5a36a9915cec71f21b0dc4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
|
Security for qbism 0.1.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.