Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
%classpath add mvn org.apache.commons commons-math3 3.6.1Loading...
Loading...
import org.apache.commons.math3.random.RandomDataGenerator
import collection.JavaConverters._
val rng = new RandomDataGenerator()scala.collection.JavaConverters$@783d0556Notice that the both of the endpoints are included, which is different from typcial Java conventions!!!
rng.nextInt(0, 2)2rng.nextInt(0, 1)1rng.nextInt(0, 1)0rng.nextPermutation(5, 3)[4, 3, 0]rng.nextPermutation(5, 3)[2, 3, 0]val vec = Vector(10, 20, 30, 40, 50)[[10, 20, 30, 40, 50]]rng.nextSample(vec.asJava, 3).mkString(" ")50 20 10rng.nextSample(vec.asJava, 3).mkString(" ")50 30 40