Reference
Result types
Instead of adding explicit measure gates, you tell QXel what you want back by attaching a Braket result type to the circuit. You can attach more than one. After the run, read them from result.values in the order you attached them.
What each type returns
Shots: sampled vs analytic
Sampled types (Sample, and Probability/Expectation/Variance estimated from shots) need shots>0. Analytic types (StateVector, Amplitude, exact Probability) need shots=0, because they read the simulator state directly instead of sampling it. StateVector and Amplitude grow with the statevector, so they are limited by memory.
Example
Attach two result types and read them back. Here probability and expectation are estimated from 1000 shots:
from braket.circuits import Circuit, Observable
circuit = Circuit().h(0).cnot(0, 1)
circuit.probability() # values[0]
circuit.expectation(Observable.Z(), target=0) # values[1]
result = qxel.run(circuit, shots=1000).result()
print(result.values)Output
[array([0.501, 0. , 0. , 0.499]), 0.002]
values[0] is the probability over '00','01','10','11' (a Bell state, so weight on '00' and '11'). values[1] is ⟨Z⟩ on qubit 0, near 0 because it is equally likely to be 0 or 1.