1
$\begingroup$

I am trying to generate expectation values of operators based on several shots. using the stim library and noticed that it has the option to get the expectation of observables using peek_observable_expectation.

I understand that I can use a for loop to collect statistics for each operator. However, I am wondering if there is a more efficient method to achieve this within stim.

Additionally, is it possible to compute the expectation values directly from the results of sampler.sample(shots=1024)? If so, how would this be done?

Any insights or examples would be greatly appreciated!

Note that I want it to be used with errors so it becomes relevant to do it.

Thank you.

$\endgroup$

1 Answer 1

0
$\begingroup$

You can use the flip simulator to efficiently sample how often the current error set anticommutes with each observable. That tells you how often they're flipped. Then the tableau simulator can be used, on a noiseless version of the circuit, to get the unflipped values. Combining the two gives the number you want.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.