{ "cells": [ { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "# Pure Data Analysis\n", "\n", "This tutorial covers different methods of analysing data *without* running GST. So far, there's only one, which checks for consistency between two (or more) datasets, called \"Data Set Comparison\".\n", "\n", "## Data Set Comparison\n", "This method declares that two or more `DataSet`s are \"inconsistent\" if the observed counts for the same gate strings across the data sets are inconsistent with being generated by the same underlying gateset. This protocol can be used to test for, among other things, drift and crosstalk. It can also be used\n", "to compare an experimental dataset to an \"ideal\" dataset. The methods in this tutorial have been presented in \"Probing context-dependent errors in quantum processors\" by Rudinger et al.\n", "\n", "Here we demonstrate the tool on simulated data from gate sets with Markovian errors. But this protocol can also be used regardless of the underlying error type." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from __future__ import division, print_function\n", "\n", "import pygsti\n", "import numpy as np\n", "import scipy\n", "from scipy import stats\n", "from pygsti.construction import std1Q_XYI" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Let's first compare two `Dataset` objects where the underlying gate sets are the same. The data sets we'll use will be GST datasets (which allows us to do some nice visualization), but arbitrary datasets will work in general, provided that the gate sequences across the datasets are the same." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "#Let's make our underlying gate set have a little bit of random unitary noise.\n", "gs_exp_0 = std1Q_XYI.gs_target.copy()\n", "gs_exp_0 = gs_exp_0.randomize_with_unitary(.01,seed=0)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "germs = std1Q_XYI.germs\n", "fiducials = std1Q_XYI.fiducials\n", "max_lengths = [1,2,4,8,16,32,64,128,256]\n", "gate_sequences = pygsti.construction.make_lsgst_experiment_list(std1Q_XYI.gates,fiducials,fiducials,germs,max_lengths)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "#Generate the data for the two datasets, using the same gate set, with 100 repetitions of each sequence.\n", "N=100\n", "DS_0 = pygsti.construction.generate_fake_data(gs_exp_0,gate_sequences,N,'binomial',seed=10)\n", "DS_1 = pygsti.construction.generate_fake_data(gs_exp_0,gate_sequences,N,'binomial',seed=20)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Statistical hypothesis tests did NOT find inconsistency between the datasets at 5.00% significance.\n" ] } ], "source": [ "#Let's compare the two datasets.\n", "comparator_0_1 = pygsti.objects.DataComparator([DS_0,DS_1])\n", "comparator_0_1.implement(significance=0.05)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "