Skip to content

Enhance GateModelResultData to support direct probability data #785

@ryanhill1

Description

@ryanhill1

The GateModelResultData.get_probabilities() method currently computes a probability distribution based on the measurement counts:

counts = self.get_counts(include_zero_values=include_zero_values, decimal=decimal)
probabilities = counts_to_probabilities(counts)

This works well for QPUs and for simulators that return raw measurement counts. However, many ideal quantum simulators compute the exact quantum state, providing deterministic results. These simulators do not involve probabilistic sampling, and the concept of shots does not apply. Consequently, these simulators do not return raw measurements or measurement counts, but instead provide direct probability data (histogram).

To better support these simulators, the GateModelResultData class should be updated to optionally accept pre-computed probabilities. This would allow get_probabilities() to return these probabilities directly, without needing to calculate them from counts.

TODO

  • Add an optional argument to the GateModelResultData class to accept pre-computed probabilities.
  • If probabilities are provided, get_probabilities() should return them directly.
  • If probabilities are not provided, get_probabilities() should maintain its current behavior of calculating probabilities based on get_counts().
  • Regardless of whether probabilities are computed from counts or provided directly, get_probabilities() should continue to respect the decimal=True/False option for formatting keys.
  • Since the function for normalizing data will now apply to both counts and direct probability histograms, consider renaming normalize_counts() to something more general, like normalize_histogram_data().

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions