{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Comparing Infidelities with SRB and XRB\n\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This example demonstrates how to estimate the process infidelities of specified\nsystems using :tqdoc:`SRB`, and how this quantity can be divided into coherent and\nstochastic infidelity by the addition of :tqdoc:`XRB` circuits. While this example\nuses a :doc:`simulator<../../guides/run/simulator>` to execute the circuits, the same\nprocedure can be followed for hardware applications.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import trueq as tq\n\n# generate SRB circuits to simultaneously characterize a single qubit [0],\n# a pair of qubits [1, 2], and another single qubit [3]\ncircuits = tq.make_srb([[0], [1, 2], [3]], [4, 32, 64], 30)\n\n# generate XRB circuits using the same arguments as SRB and combine them\ncircuits += tq.make_xrb([[0], [1, 2], [3]], [4, 32, 64], 30)\n\n# initialize a noisy simulator with stochastic Pauli and overrotation\nsim = tq.Simulator().add_stochastic_pauli(px=0.02).add_overrotation(0.04)\n\n# run the circuits on the simulator to populate their results\nsim.run(circuits, n_shots=1000)\n\n# print the fit summary\ncircuits.fit()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice that the :py:meth:`~trueq.CircuitCollection.fit` output contains an estimate\nof process infidelity for the specified systems from :tqdoc:`SRB`, the stochastic\ninfidelity from :tqdoc:`XRB`, and the unitary infidelity which would be absent if the\ncircuit collection did not contain both :tqdoc:`SRB` and :tqdoc:`XRB` circuits. We\ncan visualize the different process infidelities as follows.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# plot a comparison of process infidelities\ncircuits.plot.compare_rb()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.8" } }, "nbformat": 4, "nbformat_minor": 0 }