question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stochastic behaviour even after setting random.seed()

See original GitHub issue

numpy.random.multivariate_normal() result is not reproducible even if numpy.random.seed() is set. np.random.seed(9) class1 = np.random.multivariate_normal(mean, cov, n_samples) class2 = np.random.multivariate_normal(mean, cov, n_samples) class1 won’t be the same as class2. When I generate mean and cov with np.random.rand() it is reproducible. cov is a positive semi-definite matrix I generated using np.dot(A,A.T) where A is generated with random.rand()

This was on Python 2.7.12 with Numpy 1.11.1 on Ubuntu 16.04.1

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
sebergcommented, Sep 11, 2016

OK, I think I will close this (though feel free to keep discussing). If you think a note in the documentation would have helped you, please do have a look and open a pull request to improve it!

0reactions
gan3sh500commented, Sep 11, 2016

The data generated from each run of the code is same but from calling the function multiple times they are not. @MSeifert04 I now tried to re-set the seed and it helps a lot. Although not identical the data generated is much closer in class1 and class2. @seberg I am guessing these small changes are from the stochastic nature of the linalg part.

Thank you for the quick and helpful answers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Seemingly nondeterministic behavior despite setting Random ...
Hi all, I'm working on an optimization problem on graphs using some code I ported from R to Julia. What's strange, is that...
Read more >
On Model Stability as a Function of Random Seed
Stochastic Weight Averaging (NASWA) which improves the stability of models over random seeds. With our ASWA and NASWA based.
Read more >
How to get stable results with TensorFlow, setting random seed
Deterministic behaviour can be obtained either by supplying a graph-level or an operation-level seed. Both worked for ...
Read more >
UMAP Reproducibility — umap 0.5 documentation
UMAP is a stochastic algorithm – it makes use of randomness both to speed up ... can be reproduced exactly UMAP allows the...
Read more >
Properly Setting the Random Seed in ML Experiments. Not as ...
Machine learning models make use of randomness in obvious and unexpected ways. At a conceptual level, this non-determinism may impact your ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found