3

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?

Craig Gidney
  • 36,389
  • 1
  • 29
  • 95

1 Answers1

3

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()
simulator.set_inverse_tableau(random_tableau**-1)

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.

Craig Gidney
  • 36,389
  • 1
  • 29
  • 95