[Python] How to introduce seed in np.random.random?

Discussão em 'Python' iniciado por Stack, Junho 27, 2025.

  1. Stack

    Stack Membro Participativo

    I need to create a number of points in a square [0,1]x[0,1].

    To obtain an array of coordinates, I used:

    N_fixed_points = 10
    selection = np.random.random((N_fixed_points,2))


    which gives me a proper result.

    But I would like to reproduce the same selection output and I know that I should use a random number generator such as:

    rng = np.random.default_rng(seed=1949)


    What is the simplest way to update the selection line of code with rng?

    Continue reading...

Compartilhe esta Página