qiskit-documentation/docs/api/qiskit/0.31/qiskit.ignis.verification.Q...

277 lines
8.2 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: QVFitter (v0.31)
description: API reference for qiskit.ignis.verification.QVFitter in qiskit v0.31
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.ignis.verification.QVFitter
---
# QVFitter
<Class id="qiskit.ignis.verification.QVFitter" isDedicatedPage={true} github="https://github.com/qiskit-community/qiskit-ignis/tree/stable/0.6/qiskit/ignis/verification/quantum_volume/fitters.py" signature="QVFitter(backend_result=None, statevector_result=None, qubit_lists=None)" modifiers="class">
Bases: `object`
Class for fitters for quantum volume.
**Parameters**
* **backend\_result** (*list*) list of results (qiskit.Result).
* **statevector\_result** (*list*) the ideal statevectors of each circuit
* **qubit\_lists** (*list*) list of qubit lists (what was passed to the circuit generation)
## Methods
<span id="qiskit-ignis-verification-qvfitter-add-data" />
### add\_data
<Function id="qiskit.ignis.verification.QVFitter.add_data" signature="QVFitter.add_data(new_backend_result, rerun_fit=True)">
Add a new result. Re calculate fit
**Parameters**
* **new\_backend\_result** (*list*) list of qv results
* **rerun\_fit** (*bool*) re calculate the means and fit the result
**Raises**
**QiskitError** If the ideal distribution isnt loaded yet
#### Additional information:
Assumes that result was executed is the output of circuits generated by qv\_circuits,
</Function>
<span id="qiskit-ignis-verification-qvfitter-add-statevectors" />
### add\_statevectors
<Function id="qiskit.ignis.verification.QVFitter.add_statevectors" signature="QVFitter.add_statevectors(new_statevector_result)">
Add the ideal results and convert to the heavy outputs.
Assume the result is from statevector\_simulator
**Parameters**
**new\_statevector\_result** (*list*) ideal results
**Raises**
**QiskitError** If the result has already been added for the circuit
</Function>
<span id="qiskit-ignis-verification-qvfitter-calc-confidence-level" />
### calc\_confidence\_level
<Function id="qiskit.ignis.verification.QVFitter.calc_confidence_level" signature="QVFitter.calc_confidence_level(z_value)">
Calculate confidence level using z value.
Accumulative probability for standard normal distribution in \[-z, +infinity] is 1/2 (1 + erf(z/sqrt(2))), where z = (X - mu)/sigma = (hmean - 2/3)/sigma
**Parameters**
**z\_value** (*float*) z value in in standard normal distibution.
**Returns**
confidence level in decimal (not percentage).
**Return type**
float
</Function>
<span id="qiskit-ignis-verification-qvfitter-calc-data" />
### calc\_data
<Function id="qiskit.ignis.verification.QVFitter.calc_data" signature="QVFitter.calc_data()">
Make a count dictionary for each unique circuit from all the results.
Calculate the heavy output probability.
#### Additional information:
Assumes that result was executed is the output of circuits generated by qv\_circuits,
</Function>
<span id="qiskit-ignis-verification-qvfitter-calc-statistics" />
### calc\_statistics
<Function id="qiskit.ignis.verification.QVFitter.calc_statistics" signature="QVFitter.calc_statistics()">
Convert the heavy outputs in the different trials into mean and error for plotting.
Here we assume the error is due to a binomial distribution. Error (standard deviation) for binomial distribution is sqrt(np(1-p)), where n is the number of trials (self.\_ntrials) and p is the success probability (self.\_ydata\[0]\[depthidx]/self.\_ntrials).
</Function>
<span id="qiskit-ignis-verification-qvfitter-calc-z-value" />
### calc\_z\_value
<Function id="qiskit.ignis.verification.QVFitter.calc_z_value" signature="QVFitter.calc_z_value(mean, sigma)">
Calculate z value using mean and sigma.
**Parameters**
* **mean** (*float*) mean
* **sigma** (*float*) standard deviation
**Returns**
z\_value in standard normal distibution.
**Return type**
float
</Function>
<span id="qiskit-ignis-verification-qvfitter-plot-hop-accumulative" />
### plot\_hop\_accumulative
<Function id="qiskit.ignis.verification.QVFitter.plot_hop_accumulative" signature="QVFitter.plot_hop_accumulative(depth, ax=None, figsize=(7, 5))">
Plot individual and accumulative heavy output probability (HOP) as a function of number of trials.
**Parameters**
* **depth** (*int*) depth of QV circuits
* **ax** (*Axes or None*) plot axis (if passed in).
* **figsize** (*tuple*) figure size in inches.
**Raises**
**ImportError** If matplotlib is not installed.
**Returns**
A figure of individual and accumulative HOP as a function of number of trials, with 2-sigma confidence interval and 2/3 threshold.
**Return type**
matplotlib.Figure
</Function>
<span id="qiskit-ignis-verification-qvfitter-plot-qv-data" />
### plot\_qv\_data
<Function id="qiskit.ignis.verification.QVFitter.plot_qv_data" signature="QVFitter.plot_qv_data(ax=None, show_plt=True, figsize=(7, 5), set_title=True, title=None)">
Plot the qv data as a function of depth
**Parameters**
* **ax** (*Axes or None*) plot axis (if passed in).
* **show\_plt** (*bool*) display the plot.
* **figsize** (*tuple*) Figure size in inches.
* **set\_title** (*bool*) set figure title.
* **title** (*String or None*) text for setting figure title
**Raises**
**ImportError** If matplotlib is not installed.
**Returns**
A figure of Quantum Volume data (heavy output probability) with two-sigma error bar as a function of circuit depth.
**Return type**
matplotlib.Figure
</Function>
<span id="qiskit-ignis-verification-qvfitter-plot-qv-trial" />
### plot\_qv\_trial
<Function id="qiskit.ignis.verification.QVFitter.plot_qv_trial" signature="QVFitter.plot_qv_trial(depth, trial_index, figsize=(7, 5), ax=None)">
Plot individual trial. :param depth: circuit depth :type depth: int :param trial\_index: trial index :type trial\_index: int :param figsize: Figure size in inches. :type figsize: tuple :param ax: plot axis (if passed in). :type ax: Axes or None
**Returns**
A figure for histogram of ideal and experiment probabilities.
**Return type**
matplotlib.Figure
</Function>
<span id="qiskit-ignis-verification-qvfitter-quantum-volume" />
### quantum\_volume
<Function id="qiskit.ignis.verification.QVFitter.quantum_volume" signature="QVFitter.quantum_volume()">
Return the volume for each depth.
**Returns**
List of quantum volumes
**Return type**
list
</Function>
<span id="qiskit-ignis-verification-qvfitter-qv-success" />
### qv\_success
<Function id="qiskit.ignis.verification.QVFitter.qv_success" signature="QVFitter.qv_success()">
Return whether each depth was successful (> 2/3 with confidence level > 0.977 corresponding to z\_value = 2) and the confidence level.
**Returns**
List of list of 2 elements for each depth: - success True/False - confidence level
**Return type**
list
</Function>
## Attributes
### depths
<Attribute id="qiskit.ignis.verification.QVFitter.depths">
Return depth list.
</Attribute>
### heavy\_output\_counts
<Attribute id="qiskit.ignis.verification.QVFitter.heavy_output_counts">
Return the number of heavy output counts as measured.
</Attribute>
### heavy\_output\_prob\_ideal
<Attribute id="qiskit.ignis.verification.QVFitter.heavy_output_prob_ideal">
Return the heavy output probability ideally.
</Attribute>
### heavy\_outputs
<Attribute id="qiskit.ignis.verification.QVFitter.heavy_outputs">
Return the ideal heavy outputs dictionary.
</Attribute>
### qubit\_lists
<Attribute id="qiskit.ignis.verification.QVFitter.qubit_lists">
Return depth list.
</Attribute>
### results
<Attribute id="qiskit.ignis.verification.QVFitter.results">
Return all the results.
</Attribute>
### ydata
<Attribute id="qiskit.ignis.verification.QVFitter.ydata">
Return the average and std of the output probability.
</Attribute>
</Class>