vendredi 8 juillet 2016

Creating an Array in Spark Scala (seeded)

How do you create random seeded arrays in scala? I would want to have a random array but this random array must be the same all through out the function.

Using scala utils, we can do, for example

val arr1 = Array.fill[Float](Random.nextFloat)

However, arr1 changes everytime the process goes through it.

Since we also have seeds in scala, I've tried doing:

val rndm = Random(4)
val arr1 = Array.fill[Float](rndm.nextFloat)

Still,it changes everytime even if there is a seed.




Aucun commentaire:

Enregistrer un commentaire