Search code examples
linear-algebraquantum-computingcirq

Set random seed for cirq functions


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.


Solution

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

    np.random.seed(2)
    

    Sets the seed for cirq