In [2]:
%classpath add mvn org.apache.commons commons-math3 3.6.1
In [3]:
import org.apache.commons.math3.random.RandomDataGenerator
import collection.JavaConverters._
val rng = new RandomDataGenerator()
Out[3]:
Notice that the both of the endpoints are included, which is different from typcial Java conventions!!!
In [4]:
rng.nextInt(0, 2)
Out[4]:
In [5]:
rng.nextInt(0, 1)
Out[5]:
In [7]:
rng.nextInt(0, 1)
Out[7]:
In [3]:
rng.nextPermutation(5, 3)
Out[3]:
In [4]:
rng.nextPermutation(5, 3)
Out[4]:
In [14]:
val vec = Vector(10, 20, 30, 40, 50)
Out[14]:
In [19]:
rng.nextSample(vec.asJava, 3).mkString(" ")
Out[19]:
In [20]:
rng.nextSample(vec.asJava, 3).mkString(" ")
Out[20]: