Metrics in pyGSTi

PyGSTi contains implementation of common ways to compare quantum processes and models. You may just want to import pygsti just for this functionality, as many of the functions below act on standard NumPy arrays. Here are some of the most common functions (this tutorial is under construction, and we plan to expand it in future releases. We apologize for it's current brevity.

Let's begin by getting some gate (process) matrices for several simple 1-qubit operations. Note that Gx, Gy and Gi below are superoperator matrices in the Pauli basis - they're $4 \times 4$ real matrices. We do this for a standard model (see the standard module tutorial) and a version of this model with slightly rotated gates.

In [1]:
import pygsti.tools as tls
import pygsti.report.reportables as rptbls
from pygsti.construction import std1Q_XYI as std
import numpy as np

mdl = std.target_model()
Gx = mdl['Gx'].todense()
Gy = mdl['Gy'].todense()
Gi = mdl['Gi'].todense()

mdl_overrot = mdl.rotate( (0.1,0,0) )
Gx_overrot = mdl_overrot['Gx'].todense()
Gy_overrot = mdl_overrot['Gy'].todense()
Gi_overrot = mdl_overrot['Gi'].todense()

tls.print_mx(Gx_overrot)
   1.0000        0        0        0
        0   1.0000        0        0
        0        0  -0.0998  -0.9950
        0        0   0.9950  -0.0998

Process matrix comparisons

Fidelities

In [2]:
rptbls.entanglement_infidelity(Gx, Gx_overrot, 'pp')
Out[2]:
0.0024979173609871452
In [3]:
rptbls.avg_gate_infidelity(Gx, Gx_overrot, 'pp')
Out[3]:
0.0016652782406580968
In [4]:
rptbls.eigenvalue_entanglement_infidelity(Gx, Gx_overrot, 'pp')
Out[4]:
0.002497917360986923
In [5]:
rptbls.eigenvalue_avg_gate_infidelity(Gx, Gx_overrot, 'pp')
Out[5]:
0.0016652782406579487

Diamond distance

In [6]:
rptbls.half_diamond_norm(Gx, Gx_overrot, 'pp')
Out[6]:
0.04997916855345197
In [7]:
rptbls.eigenvalue_diamondnorm(Gx, Gx_overrot, 'pp')
Out[7]:
0.0749687539060175

Unitarity

In [8]:
tls.unitarity(Gx_overrot)
Out[8]:
1.0000000000000002

Jamiolkowski trace distance

In [9]:
rptbls.jt_diff(Gx, Gx_overrot, 'pp')
Out[9]:
0.04997916927067833

State comparisons

State fidelity

In [10]:
rhoA = tls.ppvec_to_stdmx(mdl['rho0'].todense())
rhoB = np.array( [ [0.9,   0],
                   [ 0,  0.1]], complex)
tls.fidelity(rhoA, rhoB)
Out[10]:
0.9
In [ ]: