I want to create a stim.TableauSimulator with a random tableau as its state. I know I can get a random tableau using stim.Tableau.random(num_qubits), but how do I do the same thing for the simulator?


1 Answer 1


You can use stim.TableauSimulator.set_inverse_tableau to change the tableau simulator's state to a specific tableau, such as a random tableau from stim.Tableau.random.

For example:

import stim
random_tableau = stim.Tableau.random(10)
simulator = stim.TableauSimulator()

assert simulator.current_inverse_tableau() == random_tableau**-1

Computing the inverse using **-1 isn't technically necessary here, since the distribution of inverses of random tableaus is the same as the distribution of random tableaus. But "how do I invert a tableau" is a natural followup question when learning about a method called set_inverse_tableau.


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.