python - Is there some correlation between numpy parent generator seed and its child streams? - Stack Overflow

I'm using the numpy Random Generator for a Monte Carlo simulation. In particular I'm simulati

I'm using the numpy Random Generator for a Monte Carlo simulation. In particular I'm simulating a multiple queuing scenario and I want that each arrival time in a queue is completely uncorrelated with the others. So I'm using the numpy.random.Generator.spawn which guarantees uncorrelation between the generated streams. This is my code:

import numpy as np

seed = 42
num_queues = 5

parent_generator = np.random.default_rng(seed)
streams = parent_generator.spawn(num_queues)

...

for stream in streams:
    next_arrival = stream.exponential(demand)
    # Update the i-th queue

...

Can I be 100% sure that by providing different seeds to the parent I will get completely different streams? Because as you can imagine I must be sure to execute multiple simulation rounds which are completely different between them.

I'm using the numpy Random Generator for a Monte Carlo simulation. In particular I'm simulating a multiple queuing scenario and I want that each arrival time in a queue is completely uncorrelated with the others. So I'm using the numpy.random.Generator.spawn which guarantees uncorrelation between the generated streams. This is my code:

import numpy as np

seed = 42
num_queues = 5

parent_generator = np.random.default_rng(seed)
streams = parent_generator.spawn(num_queues)

...

for stream in streams:
    next_arrival = stream.exponential(demand)
    # Update the i-th queue

...

Can I be 100% sure that by providing different seeds to the parent I will get completely different streams? Because as you can imagine I must be sure to execute multiple simulation rounds which are completely different between them.

Share Improve this question edited 18 hours ago The_Lud asked 19 hours ago The_LudThe_Lud 12 bronze badges New contributor The_Lud is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct. 2
  • 1 "Is there some correlation between numpy parent generator seed and its child streams?" Yes, the child seeds are derived from the parent seed. You should see that the child streams produce the same values in each run when you use the same parent seed. "can I be 100% sure that by providing different seeds to the parent I will get completely different streams?" Actually, you can only be sure by checking the source code. – jabaa Commented 19 hours ago
  • @jabaa Yes, you're right there was another random generation in the code which made me uncorrectly conclude that with the same seed the child streams were different – The_Lud Commented 18 hours ago
Add a comment  | 

1 Answer 1

Reset to default 0

Yes, the child seeds are derived from the parent seed. You should see that the child streams produce the same values in each run when you use the same parent seed.

Drawn numbers from each are independent but derived from the initial seeding entropy

https://numpy./doc/stable/reference/random/generated/numpy.random.Generator.spawn.html

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743763564a4503080.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信