I am shuffle
ing a list
in Kotlin
& Python
using the same seed
but i am getting different sequence. Cod on Python and Kotlin is as follows:
Kotlin
var trainInput = arrayListOf<Int>(1,2,3,4,5)
val randomSeed = 1549786796.toLong()
trainInput.shuffle(Random(randomSeed))
Output: [1, 3, 5, 2, 4]
Python:
import numpy as np
arr = np.array([1,2,3,4,5])
np.random.seed(1549786796)
np.random.shuffle(arr)
Ouput: [3 2 4 1 5]
Can anyone please point out how can I get the same sequence on both platforms?
Thanks.
EDIT
I have also checked the library java-random
(https://pypi.org/project/java-random/) suggested by Stef but this only generates the random number. I need to shuffle
the list that generates the same sequence.