	<h1> Instability Detection and Characterization </h1>

        <p>This page summarizes the results of instability ("drift") detection and characterization on time-series data. The data analysis consists of looking for evidence that the outcome probability distributions of the circuits are varying over time. In the language of hypothesis testing, the null hypothesis is that each circuit has some static (but otherwise arbitrary) probability distribution over its possible outcomes, and we are testing for violations of this null hypothesis. This report can only be generated for data from circuits with GST-like structure of germs and fiducials (e.g., GST or Ramsey data). But note that, because this analyis deals only with circuit outcome probability distributions, it is circuit-agnostic. That is, all the analysis techniques can be applied to data from any set of quantum circuit over any number of qubits, and they do not rely on, e.g., a process matrix model for the gates. 
        </p>

	    {{ drift_switchBd|render }}

    <figure id="drift_summary_table" class='tbl'>
	  <figcaption><span class="captiontitle">Results summary.</span> <span class="captiondetail">This table contains a summary of the instability detection and characterization analysis. The "global statistical significance" is the statistical significance of the set of hypothesis tests used to attempt to detect any instabilities, i.e., to detect non-constant circuit outcome probabilities. The analysis implements many statistical hypothesis tests and (by default) controls the family-wise error rate. So, if the data collection and this analysis procedure is implemented many times with circuits that contain no instabilities, then we will erroneously detect instability in one or more of our tests with a probability that is, at most, equal to this global statistical significance level. (But note that this is not guaranteed if you play around with optional arguments in the stability analysis). The table will state that instability has been detected if one ore more of the hypothesis tests detected instability (and otherwise it is false). So if this is true then there is instability in at least one circuit, with a certainty of 1 minus the global significance. If it is false then the data shows no evidence for instability (congratulations!) and the remainder of this page will then not be very interesting. The final row of this table summarizes the size of any detected instability. This is quantitified by the maximum, over circuits, of the quantity shown in one of the other figures. See the caption of the relevant figure for more information.
	  </span></figcaption>
	  {{ drift_summary_table|render }}
	</figure>

	<figure id="drift_details_table" class='tbl'>
	  <figcaption><span class="captiontitle">Analysis details.</span> <span class="captiondetail">This table contains some details of the analysis performed. This can aid in interpretting the results if you are familiar with how the methods work (and have a decent understanding of the StabilityAnalyzer object). If you ran instability analysis using the do_instability_anlaysis() function and didn't alter any of the more subtle optional arguments (e.g., the "inclass_correction"), then you shouldn't need to worry about the contents of this table. The first row tells you the type of transform used to generate power spectra. The second row tells you whether more than one set of hypothesis tests have been run for instability detection. If it is true then the family-wise error rate is possibly not strictly being controlled - so make sure you know what you're doing if this is false!</span></figcaption>
	  {{ drift_details_table|render }}
	</figure>

	<figure id="global_power_spectra_plot" class='tbl'>
	  <figcaption><span class="captiontitle">Global power spectrum.</span> <span class="captiondetail">The analysis is based on generating power spectra from the data: the time series of counts for each outcome of each circuit is transformed into the frequency domain using some Fourier-like transform (often the discrete cosine transform). If the data is sampled from a time-invariant probability distribution, each power in these spectra has an expected value of 1 and a known distribution (often it <span class="math">\chi^2_1</span>). So we can test for violations of this, by looking for powers that are too high to be consistent with the time-invariant probability distribution hypothesis. One way to test the power spectra is to first average all of them, which suppresses the measurement shot-noise at the cost of losing diagonstic information about which circuits are unstable. This plot shows this averaged power spectrum. All powers above the threshold are statistically significant: the probability trajectories for one or more of the circuits contain components at the corresponding frequencies (with a certainity of 1 minus the global statistical significance level). This threshold has been adjusted to control the FWER of all the tests being implemented. Note that the height of the peaks in this spectrum is only an indirect measure of the size of any instability, e.g., the height of a peak will often increase linearly with the number of data collection times. Frequencies are shown in Hertz, which assumes that the time stamps in the analyzed DataSet are in seconds (in general, the frquencies are in 1/units where "units" is the units of the time stamps). </span></figcaption>
	  {{ global_power_spectra_plot|render }}
	</figure>

	<figure id="germ_fiducial_power_spectra_plot" class='tbl'>
	  <figcaption><span class="captiontitle">Power specta.</span> <span class="captiondetail"> The set of power spectra for a fiducial-germ-fiducial triple, as the number of times the germ is repeated is varied. To select the fiducial-germ-fiducial triple use the tabs shown elewhere on this page. Each power is approximately <span class="math">\chi^2_{m-1}</span> distributed under the null hypothesis of stable circuits, with <span class="math">m</span> the number of possible measurement outcomes for the circuits. All powers above the threshold are statistically significant: the probability trajectories for the corresponding circuit contains components at the corresponding frequencies (with a certainity of 1 minus the global statistical significance level). This threshold has been adjusted to control the FWER of all the tests being implemented. Note that the height of the peaks in these spectra are only an indirect measure of the size of any instability, e.g., the height of a peak will often increase linearly with the number of data collection times. Frequencies are shown in Hertz, which assumes that the time stamps in the analyzes DataSet are in seconds (in general, the frquencies are in 1/units where "units" is the units of the time stamps). </span></figcaption>
	  {{ germ_fiducial_power_spectra_plot|render }}
	</figure>

	<figure id="germ_fiducial_prob_trajectories_plot" class='tbl'>
	  <figcaption><span class="captiontitle">Estimated probability trajectories.</span> <span class="captiondetail"> The analysis techniques estimate the outcome probability distribution for each circuit over time. We refer to the probability to obtain some outcome over time as a "probability trajectory". This plot shows the set of probability trajectories for a particular measurement outcome and a particular fiducial-germ-fiducial triple, as the number of times the germ is repeated is varied. To select the fiducial-germ-fiducial triple, and the measurement outcome, use the tabs shown elewhere on this page. Each probability trajectory estimate is obtained by (1) selecting a parameterized model for the probability trajectory, and (2) estimating the parameters of that model by fitting it to the time-series data for the corresponding circuit. The model selection stage is implemented using the results of the instability detection: the selected parameterized model contains a time-invariant component + a sum of cosines (multiplied by arbitary amplitudes) at those and only those frequencies that have been deemed to be components in the probability trajectory via the hypothesis tests. Normally, this is exactly those frequencies that have power above the significance threshold in the power spectrum for that circuit (see the other plot), and so a probability trajectory is estimated to be constant if no frequencies have power above the threshold. This is the default behavior of the analysis, but these frequencies can also be chosen in other ways if the default values for the do_instability_analysis() functions were not used to generate these results (the estimation method can be ascertained from the Analysis details table).</span></figcaption>
	  {{ germ_fiducial_prob_trajectories_plot|render }}
	</figure>

    <figure id="drift_detector_colorbox_plot" class='tbl'>
	  <figcaption><span class="captiontitle">The evidence for instability in each circuit.</span> <span class="captiondetail">This plot summarizes the evidence for instability in each circuit, using <span class="math">\lambda - \log_{10}(\mathrm{p})</span> where p is the p-value of the maximum power in the power spectrum for that circuit. A pixel is greyscale if <span class="math">\lambda</span> is not statistically significant, i.e, the maximum power in the spectrum is below the statitical significance threshold. A pixel is green if <span class="math">\lambda</span> is statistically significant, i.e, the maximum power in the spectrum is above the statistical significance threshold. As the family-wise error rate is (by default) controlled in the hypothesis testing, the chances that any box shows up green when all the circuits are stable is, at most, the global statistical significance of the tests, shown in the Summary table. Note that, for technical reasons, <span class="math">\lambda</span> is truncated from above at 16.</span></figcaption>
	  {{ drift_detector_colorbox_plot|render }}
	</figure>

	<figure id="drift_size_colorbox_plot" class='tbl'>
	  <figcaption><span class="captiontitle">The size of the instability in each circuit.</span> <span class="captiondetail">This plot summarizes the size of the instability detected in each circuit. This is quantified by half the sum of the absolute value of the amplitudes in front of the non-constant basis functions for the estimated probability trajectories for the circuit. This is an upper bound on the maximum TVD between the instantaneous probability distribution at some time from the mean of the trajectory, maximized over times. Typically, many of the probability trajectories estimates will be constants (at least with the default analysis settings), and so this plot will likely contain a lot of white boxes.</span></figcaption>
	  {{ drift_size_colorbox_plot|render }}
	</figure>





	



