1
$\begingroup$

I am developing a sampling algorithm using Fourier analysis of Boolean functions for which I use Google's Cirq to obtain the state vector with .simulate().

I wanted to know what sampling algorithm Google Cirq implements with .sample() so that I can have a better idea of how to benchmark it against my algorithm. I have been looking at the docs and source code of cirq.sim.Simulator (https://quantumai.google/reference/python/cirq/sim/Simulator), but I cannot find what sampling algorithm their .run() and .sample() methods use.

$\endgroup$
0

1 Answer 1

0
$\begingroup$

cirq.Simulator() uses a statevector simulation algorithm. The resulting statevector is sampled from by first squaring the amplitudes to obtain a probability vector followed by a call to numpy.random.Generator.choice (Here's where it happens) on the probability vector to generate the results.

$\endgroup$
3
  • 1
    $\begingroup$ Thank you so much! Makes total sense now that I see what cirq.value is and .parse_random_state() The only thing they do is to give the probability distribution and with choice() numpy takes care of giving the resultant values. Thanks again! I was wondering because I am using fourier coefficients to see how I can add noise to the probability distribution and how the XEB is affected by this, so I thought it would make sense to compare it with their .sample() method, but now that I see that they are using the ideal distribution I do not really need to do that. $\endgroup$
    – Pablo
    Mar 12 at 14:20
  • $\begingroup$ You're welcome! Please "Upvote" and "Accept" my answer so that people who find this question in the future can readily know that it answers your question. $\endgroup$ Mar 13 at 7:38
  • 1
    $\begingroup$ apologies! just did it. $\endgroup$
    – Pablo
    Mar 14 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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