In [81]:
% load_ext autoreload
% autoreload 2
% matplotlib inline

from matplotlib import pyplot as plt
import numpy as np
import pandas as pd
import scipy as sp
import seaborn as sns
np.set_printoptions(precision=4, linewidth=120)
from tqdm import *
from drift_qec.A import *


The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload

Covariance-weighted update


In [157]:
D = 0.25*np.pi
channel = Channel(kx=0.7, ky=0.2, kz=0.1, Q=FIXEDQ,
                  n=1e2, d1=D, d2=D, d3=D)
for _ in range(1000):
    channel.update()
print channel.C
print channel.M


[[ 0.1317  0.1109 -0.0285]
 [ 0.1109  0.5553 -0.2122]
 [-0.0285 -0.2122  0.3128]]
[[ 0.1987  0.15   -0.0149]
 [ 0.15    0.4867 -0.1574]
 [-0.0149 -0.1574  0.3147]]

In [156]:
D = 0.25 * np.pi
channel = Channel(kx=0.7, ky=0.2, kz=0.1, Q=FIXEDQ,
                  n=1e5, d1=D, d2=D, d3=D)
channel.update()
print channel.C
print channel.M


[[ 0.1317  0.1109 -0.0285]
 [ 0.1109  0.5553 -0.2122]
 [-0.0285 -0.2122  0.3128]]
[[ 0.1329  0.1086 -0.0256]
 [ 0.1086  0.5543 -0.2101]
 [-0.0256 -0.2101  0.3129]]

Simulate this


In [ ]:
D = 0.25*np.pi
D = 0.01
channel = Channel(kx=0.7, ky=0.2, kz=0.1,
                  Q=np.linalg.qr(np.random.randn(3,3))[0],
                  n=1e3, d1=D, d2=D, d3=D)

In [ ]:
channel.update()

In [ ]:
channel.C

In [ ]:
channel.Mhat

In [ ]:
Q  = np.linalg.qr(np.random.randn(3,3))[0]
C  = np.random.random((3,3))

print np.reshape(np.dot(np.dot(Q, C), Q.T), (9,))
print np.dot(np.kron(Q, Q), np.reshape(C, (9,)))

In [ ]:
CYCLES = range(1000)
D = 0.25*np.pi
channel = Channel(kx=0.7, ky=0.2, kz=0.1,
                  Q=np.linalg.qr(np.random.randn(3,3))[0],
                  n=1e1, d1=D, d2=D, d3=D)

RECORDS = []
for cycle in CYCLES:
    qxhat = np.linalg.eig(channel.Mhat)[1][:, 0]
    qxval = channel.Q[:, 0]
    RECORDS.append({
            "cycle": cycle,
            "d1", channel.d1, "d2", channel.d2, "d3", channel.d3,
            "qxhat1": qxhat[0], "qxhat2": qxhat[1], "qxhat3": qxhat[2],
            "qxval1": qxval[0], "qxval2": qxval[1], "qxval3": qxval[2]
        })
    channel.update()
    channel.d1, channel.d2, channel.d3 =