View source on GitHub |
The results of running on an IonQ simulator.
cirq_ionq.results.SimulatorResult(
probabilities: Dict[int, float],
num_qubits: int,
measurement_dict: Dict[str, Sequence[int]],
repetitions: int
)
The IonQ simulator returns the probabilities of the different outcomes, not the raw state vector or samples.
Methods
measurement_dict
measurement_dict() -> Dict[str, Sequence[int]]
Returns a map from measurement keys to target qubit indices for this measurement.
num_qubits
num_qubits() -> int
Returns the number of qubits the circuit was run on.
probabilities
probabilities(
key: Optional[str] = None
) -> Dict[int, float]
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.LineQubit
s 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
repetitions() -> int
Returns the number of times the circuit was run.
For IonQ API simulations this is used when generating cirq.Result
s from to_cirq_result
.
The sampling is not done on the IonQ API but is done in to_cirq_result
.
to_cirq_result
to_cirq_result(
params: Optional[cirq.ParamResolver] = None,
seed: cirq.RANDOM_STATE_OR_SEED_LIKE = None,
override_repetitions=None
) -> cirq.Result
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.Result
s. 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__
__eq__(
other
)
Return self==value.