Skip to main content

quantum bettabilitarianism

Project description

QBism

PyPI version

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_krauss(0, [2,2]), povm4, povm2)
ptrB = povm_map(partial_trace_krauss(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!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qbism-0.0.8.tar.gz (264.0 kB view details)

Uploaded Source

Built Distribution

qbism-0.0.8-py3-none-any.whl (295.0 kB view details)

Uploaded Python 3

File details

Details for the file qbism-0.0.8.tar.gz.

File metadata

  • Download URL: qbism-0.0.8.tar.gz
  • Upload date:
  • Size: 264.0 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for qbism-0.0.8.tar.gz
Algorithm Hash digest
SHA256 6ad1e58473329a91b37deda198d53f762a67768c1c64e660daccb6455be45a44
MD5 25c10855f4ebf29bde9d46fcf1b28448
BLAKE2b-256 42cc1a7f7921af91e52b3488ecb0a1a83f2f07448784b9a4e04cfca0680e4e8b

See more details on using hashes here.

File details

Details for the file qbism-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: qbism-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 295.0 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for qbism-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 4940a4b4ee374dd18110d5834d81f03028729ed9bcd004b964ae421c6080eea9
MD5 1dae2e5c65dd1625b5e9c575e73bed76
BLAKE2b-256 b32df38f4c40754249634c0b1513e9dd29341d0d32f7e10e789a097d831e3ff1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page