@@ -0,0 +1,1499 @@
+import java.util.Random;%0A%0A/*%0A * This snippet uses some useful random functions.%0A *%0A * Usage:%0A * - compile: javac RandomFunctions.java%0A * - execute: java RandomFunctions%0A */%0A%0Apublic class RandomFunctions %7B%0A%0A%09/**%0A%09 * @param args%0A%09 */%0A%09public static void main(String%5B%5D args) %7B%0A%0A%09%09// Default seed (time) ////////////////////////////////////////////////%0A%0A%09%09Random rand = new Random();%0A%0A%09%09// Get a pseudorandom integer, uniformly distributed between 0 and n.%0A%09%09int n = 10;%0A%09%09System.out.println(rand.nextInt(n));%0A%0A%09%09// Get a pseudorandom Gaussian (%22normally%22) distributed double value%0A%09%09// with mean 0.0 and standard deviation 1.0.%0A%09%09System.out.println(rand.nextGaussian());%0A%0A%09%09// Get a pseudorandom boolean, uniformly distributed boolean value.%0A%09%09System.out.println(rand.nextBoolean());%0A%0A%09%09// Get a pseudorandom double, uniformly distributed double value between%0A%09%09// 0.0 and 1.0.%0A%09%09System.out.println(rand.nextDouble());%0A%0A%09%09// Get a pseudorandom float, uniformly distributed float value between%0A%09%09// 0.0 and 1.0.%0A%09%09System.out.println(rand.nextFloat());%0A%0A%09%09// Get a pseudorandom uniformly distributed integer value from this%0A%09%09// random number generator's sequence.%0A%09%09System.out.println(rand.nextInt());%0A%0A%09%09// Get a pseudorandom uniformly distributed long value.%0A%09%09System.out.println(rand.nextLong());%0A%0A%09%09%0A%09%09// Custom seed (time) /////////////////////////////////////////////////%0A%0A%09%09Random custom_rand = new Random(0); // Here 0 is used as custom seed%0A%0A%09%09System.out.println(custom_rand.nextInt());%0A%0A%09%7D%0A%0A%7D%0A

Add some snippets (Java).