0

I am generating a random number drawn from U(0,1) using the following Scala code:

scala.util.Random(seed).nextDouble(), where seed is an integer.

Is there a way to generate the same random number based on the same seed in Python? I've tried using numpy and pyspark implementations, but still am not generating the exact same random number as the Scala code.

Suma
  • 33,181
  • 16
  • 123
  • 191
riggsmir
  • 21
  • 4
  • 1
    Does this answer your question? [random.seed(): What does it do?](https://stackoverflow.com/questions/22639587/random-seed-what-does-it-do) – Abhinav Mathur Mar 07 '22 at 06:22
  • 1
    @AbhinavMathur They want to generate the exact same random number as Scala in Python. Note that Scala implementation uses Java, so it should be possible with https://pypi.org/project/java-random/ – Selcuk Mar 07 '22 at 06:35
  • @Selcuk That package does exactly what I need, thank you! – riggsmir Mar 08 '22 at 04:35

0 Answers0