Note
This is the documentation for the current state of the development branch of Qiskit Experiments. The documentation or APIs here can change prior to being released.
MockIQExperimentHelper.compute_probabilities¶
- abstract MockIQExperimentHelper.compute_probabilities(circuits)[source]¶
A function provided by the user which is used to determine the probability of each output of the circuit. The function returns a list of dictionaries, each containing output binary strings and their probabilities.
Examples:
1 qubit circuit - excited state
In this experiment, we want to bring a qubit to its excited state and measure it. The circuit:
┌───┐┌─┐ q: ┤ X ├┤M├ └───┘└╥┘ c: 1/══════╩═ 0
The function that calculates the probability for this circuit doesn’t need any calculation parameters:
@staticmethod def compute_probabilities(self, circuits: List[QuantumCircuit]) -> List[Dict[str, float]]: output_dict_list = [] for circuit in circuits: probability_output_dict = {"1": 1.0, "0": 0.0} output_dict_list.append(probability_output_dict) return output_dict_list
3 qubit circuit
In this experiment, we prepare a Bell state with the first and second qubit. In addition, we will bring the third qubit to its excited state. The circuit:
┌───┐ ┌─┐ q_0: ┤ H ├──■──┤M├─── └───┘┌─┴─┐└╥┘┌─┐ q_1: ─────┤ X ├─╫─┤M├ ┌───┐└┬─┬┘ ║ └╥┘ q_2: ┤ X ├─┤M├──╫──╫─ └───┘ └╥┘ ║ ║ c: 3/═══════╩═══╩══╩═ 2 0 1
When an output string isn’t in the probability dictionary, the backend will assume its probability is 0.
@staticmethod def compute_probabilities(self, circuits: List[QuantumCircuit]) -> List[Dict[str, float]]: output_dict_list = [] for circuit in circuits: probability_output_dict = {} probability_output_dict["001"] = 0.5 probability_output_dict["111"] = 0.5 output_dict_list.append(probability_output_dict) return output_dict_list
- Return type:
List
[Dict
[str
,Any
]]