1

I was reading this blog post and they suggest that rather than setting the random seed for the whole document

np.random.seed(1234)
x = np.random.randn(100)

One should use a generator, which can be created as such

rng = np.random.default_rng(1234)

In the post they use the example of rng.rand(10) which works fine. I need to use randn() however and it doesn't work if you use rng.randn(10).

1 Answer 1

4

You can use rng.normal(10) instead.

The normal method is the equivalent of randn but using a random generator instance.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.