Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A student runs a simulation twice, and gets different answers. A teacher says that the simulation is not reproducible. Show with NumPy that two generators with the same seed give the same five rolls of a die, and that two generators made without a seed do not. Why does it matter in science?
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Plan. Make the generators, ask both for five rolls, and compare the arrays.
Check. The first line shows the same five numbers twice and True. The second line is, with overwhelming probability, False: two sequences of 50 rolls without a seed are almost never equal (the chance is ).
Answer: the same seed gives the same numbers. It matters because a result that cannot be repeated cannot be checked. A published simulation should give its seed, so that anyone can run it and get the same numbers.
Log in to join the discussion.
Loading…