CompositeCurveAnalysis

class CompositeCurveAnalysis(analyses, name=None)[source]

Composite Curve Analysis.

The CompositeCurveAnalysis takes multiple curve analysis instances and performs each analysis on the same experimental results. These analyses are performed independently, thus fit parameters have no correlation. Note that this is different from CompositeAnalysis which analyses the outcome of a composite experiment, in which multiple different experiments are performed. The CompositeCurveAnalysis is attached to a single experiment instance, which may execute similar circuits with slightly different settings. Experiments with different settings might be distinguished by the circuit metadata. The outcomes of the same set of experiments are assigned to a specific analysis instance in the composite curve analysis. This mapping is usually done with the analysis option filter_data dictionary. Otherwise, all analyses are performed on the same set of outcomes.

Examples

In this example, we write up a composite analysis consisting of two oscillation analysis instances, assuming two Rabi experiments in 1-2 subspace starting with different initial states \(\in \{|0\rangle, |1\rangle\}\). This is a typical procedure to measure the thermal population of the qubit.

from qiskit_experiments import curve_analysis as curve

analyses = []
for qi in (0, 1):
    analysis = curve.OscillationAnalysis(name=f"init{qi}")
    analysis.set_options(
        filter_data={"init_state": qi},
    )
analysis = CompositeCurveAnalysis(analyses=analyses)

This analysis will return two analysis result data for the fit parameter “freq” for experiments with the initial state \(|0\rangle\) and \(|1\rangle\). The experimental circuits starting with different initial states must be distinguished by the circuit metadata {"init_state": 0} or {"init_state": 1}, along with the “xval” in the same dictionary.

CompositeCurveAnalysis subclass may override following methods.

_evaluate_quality

This method evaluates the quality of the composite fit based on the all analysis outcomes. This returns “good” when all fit outcomes are evaluated as “good”, otherwise it returns “bad”.

_create_analysis_results

This method is passed all the group fit outcomes and can return a list of new values to be stored in the analysis results.

_create_figures

This method creates figures by consuming the scatter table data. Figures are created when the analysis option plot is True.

Initialize the analysis object.

Attributes

models

Return fit models.

name

Return name of this analysis.

options

Return the analysis options for run() method.

parameters

Return parameters of this curve analysis.

plotter

A short-cut to the plotter instance.

Methods

analyses(index=None)[source]

Return curve analysis instance.

Parameters:

index (int | str | None) – Name of group or numerical index.

Returns:

Curve analysis instance.

Return type:

BaseCurveAnalysis | List[BaseCurveAnalysis]

config()

Return the config dataclass for this analysis

Return type:

AnalysisConfig

copy()

Return a copy of the analysis

Return type:

BaseAnalysis

classmethod from_config(config)

Initialize an analysis class from analysis config

Return type:

BaseAnalysis

run(experiment_data, replace_results=False, **options)

Run analysis and update ExperimentData with analysis result.

Parameters:
  • experiment_data (ExperimentData) – the experiment data to analyze.

  • replace_results (bool) – If True clear any existing analysis results, figures, and artifacts in the experiment data and replace with new results. See note for additional information.

  • options – additional analysis options. See class documentation for supported options.

Returns:

An experiment data object containing analysis results, figures, and artifacts.

Raises:

QiskitError – If experiment_data container is not valid for analysis.

Return type:

ExperimentData

Note

Updating Results

If analysis is run with replace_results=True then any analysis results, figures, and artifacts in the experiment data will be cleared and replaced with the new analysis results. Saving this experiment data will replace any previously saved data in a database service using the same experiment ID.

If analysis is run with replace_results=False and the experiment data being analyzed has already been saved to a database service, or already contains analysis results or figures, a copy with a unique experiment ID will be returned containing only the new analysis results and figures. This data can then be saved as its own experiment to a database service.

set_options(**fields)[source]

Set the analysis options for run() method.

Parameters:

fields – The fields to update the options