2

I am working with cirq and use a random unitary for testing purposes with:

random_matrix = cirq.testing.random_unitary(dim=4)

where can can the random seed for this function be set, using random.seed(a=1) does not seem to do this.

Adam Zalcman
  • 26,643
  • 4
  • 71
  • 92
Marsh
  • 41
  • 6
  • Solved: use np.random.seed() not random.seed() – Marsh Dec 11 '20 at 15:48
  • When you have found the solution, you can also add an answer (answer your own question), which you can then accept for other people who have the same problem. In a answer, it is more meaningful than in a comment. – SwissCodeMen Dec 12 '20 at 10:53

1 Answers1

2

Cirq relies on numpy for its random functions, so using:

np.random.seed(2)

Sets the seed for cirq

Marsh
  • 41
  • 6
  • 1
    To follow up, the documentation describing this is here https://quantumai.google/cirq/simulation: "The actual measurement results depend on the seeding from random seed generator (numpy) . You can set this using numpy.random_seed." – nikojpapa Jan 19 '21 at 17:44