Proof of concept implementation of coroutine-bound...
# mathematics
a
Proof of concept implementation of coroutine-bound random number generator for parallel and synchronous deterministic operations with random numbers: https://github.com/mipt-npm/kmath/blob/split-random/kmath-prob/src/jvmMain/kotlin/scientifik/kmath/prob/MCScope.kt. I am not sure that it is the best solution, but it seems to be working properly. The idea is that generator is bound to a coroutine (not the thread) and the generator splits each time new child coroutine is created (we need a special generator for that). As a result, the random number generated in each specific act depend only on initial seed, not on execution order, dispatcher or number of threads (the result of https://github.com/mipt-npm/kmath/blob/split-random/kmath-prob/src/jvmTest/kotlin/scientifik/kmath/prob/MCScopeTest.kt is the same for any dispatcher). Comments and contributions are welcome. Tracking issue: https://github.com/mipt-npm/kmath/issues/65
👍 3