admin管理员组文章数量:1345707
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
1 Answer
Reset to default 0Yes, 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
版权声明:本文标题:python - Is there some correlation between numpy parent generator seed and its child streams? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743763563a2534827.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论