holgerbrandl
01/22/2021, 9:04 PMkotlin.random.Random.Default
so that running listOf(1,2,3).shuffled()
twice would give the same result. Controlling randomess is an important feature of every language that is intended for data-science (see https://www.w3schools.com/python/ref_random_seed.asp for python or https://www.rdocumentation.org/packages/simEd/versions/1.0.3/topics/set.seed for RShawn
01/22/2021, 9:10 PMval random = Random(42)
), and if “controlling randomness” is important in your application, you should make calls to RNG instances you control instead of relying on the Random.Default
singletonholgerbrandl
01/22/2021, 9:19 PMholgerbrandl
01/22/2021, 9:21 PMDerek Peirce
01/25/2021, 12:59 AMshuffled()
could be modified to take a Random
as an argument, with a default of Random.Default
. However, the library would then have to declare either that it commits to using the same sequence of random-value calls for all future updates, or that the same seed may lead to different results after an update to the stdlib.Derek Peirce
01/25/2021, 1:01 AMilya.gorbunov
01/25/2021, 2:40 PMRandom.Default
, for example being able to set its seed with some global method.
In fact, having such globally mutable seed in a concurrent environment doesn't make further random calls anymore predictable.holgerbrandl
01/29/2021, 4:40 PM