cirq_ionq.results.SimulatorResult

The results of running on an IonQ simulator.

The IonQ simulator returns the probabilities of the different outcomes, not the raw state vector or samples.

Methods

measurement_dict

View source

Returns a map from measurement keys to target qubit indices for this measurement.

num_qubits

View source

Returns the number of qubits the circuit was run on.

probabilities

View source

Returns the probabilities of the measurement results.

If a key parameter is supplied, these are the probabilities for the measurement results for the qubits measured by the measurement gate with that key. If no key is given, these are the measurement results from measuring all qubits in the circuit.

The key in the returned dictionary is the computational basis state measured for the qubits that have been measured. This is expressed in big-endian form. For example, if no measurement key is supplied and all qubits are measured, the key in this returned dict has a bit string where the cirq.LineQubits are expressed in the order: (cirq.LineQubit(0), cirq.LineQubit(1), ..., cirq.LineQubit(n-1)) In the case where only r qubits are measured corresponding to targets t_0, t1,...t{r-1}, the bit string corresponds to the order (cirq.LineQubit(t_0), cirq.LineQubit(t1), ... cirq.LineQubit(t{r-1}))

The value is the probability that the corresponding bit string occurred.

See to_cirq_result to convert to a cirq.Result.

repetitions

View source

Returns the number of times the circuit was run.

For IonQ API simulations this is used when generating cirq.Results from to_cirq_result. The sampling is not done on the IonQ API but is done in to_cirq_result.

to_cirq_result

View source

Samples from the simulation probability result, producing a cirq.Result.

The IonQ simulator returns the probabilities of different bitstrings. This converts such a representation to a randomly generated sample from the simulator. Note that it does this on every subsequent call of this method, so repeated calls do not produce the same cirq.Results. When a job was created by the IonQ API, it had a number of repetitions and this is used, unless override_repetitions is set here.

Args
params Any parameters which were used to generated this result.
seed What to use for generating the randomness. If None, then np.random is used. If an integer, np.random.RandomState(seed) is used. Otherwise if another randomness generator is used, it will be used. </td> </tr><tr> <td>override_repetitions` Repetitions were supplied when the IonQ API ran the simulation, but different repetitions can be supplied here and will override.

Returns
A cirq.Result corresponding to a sample from the probability distribution returned from the simulator.

Raises
ValueError If the circuit used to produce this result had no measurement gates (and hence no measurement keys).

__eq__

View source

Return self==value.