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
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743763564a4503080.html
评论列表(0条)