Python Tools Related to Tomography (tomographer.tools)¶
The tools collected in these modules are separated from the other modules, because in contrast to the other modules (except for jpyutil and querrorbars), these do not interface any C++ code and are written in pure Python.
Simulating Measurements, and More (tomographer.tools.densedm)¶
This module collects utilities gravitating around some standard tasks you may need to perform when doing quantum tomography.
A routine allows you to simulate measurement outcomes from a true quantum state and a set
of measurement settings. The standard Pauli measurement settings on a qubit are available
in PauliMeasEffectsQubit
.
A separate submodule (mle
) determines the maximum
likelihood estimate given experimental data.
Further tools may be added to these modules in the future.

tomographer.tools.densedm.
PauliMeasEffectsQubit
= [[array([[ 0.5, 0.5], [ 0.5, 0.5]]), array([[ 0.5, 0.5], [0.5, 0.5]])], [array([[ 0.5+0.j , 0.00.5j], [ 0.0+0.5j, 0.5+0.j ]]), array([[ 0.5+0.j , 0.0+0.5j], [0.00.5j, 0.5+0.j ]])], [array([[1, 0], [0, 0]]), array([[0, 0], [0, 1]])]]¶ List of POVMs corresponding to measuring Pauli operators on a single qubit.
PauliMeasEffectQubit[i][s]
is the POVM effect corresponding to measuring the outcome indexed by s of the Pauli operator indexed by i.

tomographer.tools.densedm.
simulate_measurements
(rho, Mk, num_samples_per_setting)¶ Simulate measurements for quantum tomography.
The “true state” rho should be a numpy.array object, as well as each POVM effect in Mk.
Mk should be a list of lists of POVM effects, where
Mk[k][i]
is the POVM effect corresponding to outcome i of measurement setting k. A POVM effect must be a positive semidefinite matrix (given as a NumPy array), and all effects of a measurement setting should sum up to the identity matrix.num_samples_per_setting specifies the number of repetitions of a measurement setting. If it is an integer, then we simulate this number of measurement outcomes for each measurement setting in Mk. If it is a list (or a numpy.array), then it should have the same length as there are settings in Mk (i.e.
len(Mk) == len(num_samples_per_setting)
), and for the kth measurement setting in Mk we will simulatenum_samples_per_setting[k]
number of outcomes.Returns: an object d with properties d.Emn and d.Nm, representing the POVM effects and simulated frequency counts. They are in a format suitable for input to
tomographer.tomorun.tomorun()
ortomographer.densedm.IndepMeasLLH
.
Maximum Likelihood Estimation (tomographer.tools.densedm.mle)¶
Utility to find the MLE estimate, using cvxpy.

tomographer.tools.densedm.mle.
DEFAULT_SOLVER_OPTS
= {'eps': 1e06, 'max_iters': 5000, 'solver': 'SCS', 'verbose': True}¶ The default solver options used by
find_mle()
.

tomographer.tools.densedm.mle.
find_mle
(llh, solver_opts=None)¶ Find the Maximum Likelihood Estimate state. The measurement data is specified in the llh argument as a
tomographer.densedm.IndepMeasLLH
instance.This function creates and solves a cvxpy problem solving the following:
\[ \begin{align}\begin{aligned}\text{maximize:}\quad &\sum_k N_k \ln\operatorname{tr}(E_k\cdot\rho)\\\text{subject to:}\quad &\rho \geqslant 0\\ &\operatorname{tr}\rho = 1\end{aligned}\end{align} \]The return value of this function is an twotuple (rho_MLE, d), where rho_MLE is a numpy.array representing the maximum likelihood estimate, and where d is an object with the following attributes set:
d.result
: the raw return value of cvxpy.solve()d.rho_MLE
: a copy of rho_MLEd.rho_vars
: a twotuple (rho_R, rho_I,) of the raw cvxpy variables used to represent the complex variable rho. (Cvxpy doesn’t support complex variables, so we need to declare two real matrix variables, corresponding to the real and imaginary parts of the variable rho.)d.objective
: the raw optimization objective object constructed for cvxpyd.constraints
: the list of constraints specified to cvxpyd.problem
: the raw cvxpy problem object
The optional solve_opts argument is a dictionary of options that are directly passed on to cvxpy. The keys specified in solve_opts override the default keys in
DEFAULT_SOLVER_OPTS
.