-2

According to What does numpy.random.seed(0) do?, we understand the usage concept of this code.

But, How we can understand what value is appropriate for seed? For example, in http://emcee.readthedocs.io/en/latest/tutorials/line/ we can see the value (123) and (42). np.random.seed(123) and np.random.seed(42). is it based on specific principle? This question is fo the important reason, In many codes if we change the value of seed the out puts will be wrong and we have another answer not what we did expect!

I appreciate your help and your attention.

David
  • 63
  • 1
  • 11
  • 3
    It is just any arbitrarily known chosen value in case you need to replicate the same sequence of numbers at a later time (using the same seed) – sshashank124 Feb 20 '18 at 14:53
  • @sshashank124 Thank you, You mean that this 123 and 42 are obtained experimentally? and we must trust it? – David Feb 20 '18 at 14:55
  • No, the person writing the code just chose that value – sshashank124 Feb 20 '18 at 14:56
  • Here's a better explanation:https://stackoverflow.com/questions/22639587/random-seed-what-does-it-do – sshashank124 Feb 20 '18 at 14:57
  • @sshashank124 No it is the same question but not about the number. if we choose 121 or 129 or anything else the out put would be changed. I would like to know how do we can understand 42 or 123 is the proper number. why no 124 or why not 40 or the other numbers. – David Feb 20 '18 at 15:05
  • 2
    The number chosen is arbitrary. It is only to guarantee that if you use the same number in the future. You will get the same sequence of pseudo-random values. That is the property of a seed. Any value for the seed will work in this way. 42 and 123 are nothing special in this or any other context – sshashank124 Feb 20 '18 at 15:07
  • 1
    @sshashank124 Yes, definitely and thank you for your answer. Your state is true. But I think the author chose those numbers to obtain the answer close to the initial point. Because if we chose 120 instead of 123 the out puts would be wrong, as well as 42. Thank you for your Help. – David Feb 20 '18 at 15:12

1 Answers1

0

The values suggested in the emcee article are likely a pun (especially 42; see). If the random generator is providing good-enough pseudo-random values you can pretty much take any arbitrary number in the range of its cycle for a start and there should be no particular difference in the quality of the 'randomness' you get. Of course (as with passwords) there are some more common values that people would take than others (e.g. 123, 42, 1234, etc.). These are good to be avoided.

sophros
  • 14,672
  • 11
  • 46
  • 75