tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Uncommons Maths > Cellular Automaton Random Number Generator

Cellular Automaton Random Number Generator 

Uncommons Maths is a java library with nice math utilities and random number generators. This requires the library uncommons-maths-1.2.2.jar to be in classpath. The following example shows using CellularAutomatonRNG class.

File Name  :  
com/bethecoder/tutorials/uncommons/CellularAutomatonRNGTest.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.uncommons;

import java.util.Arrays;
import org.uncommons.maths.random.CellularAutomatonRNG;

public class CellularAutomatonRNGTest {

  /**
   @param args
   */
  public static void main(String[] args) {

    CellularAutomatonRNG rand = new CellularAutomatonRNG();
    System.out.println(Arrays.toString(rand.getSeed()));
    
    System.out.println(rand.nextInt());
    System.out.println(rand.nextDouble());
    System.out.println(rand.nextGaussian());
    System.out.println(rand.nextBoolean());
  }

}
   

It gives the following output,
[-46, 53, -124, -19]
446193669
0.3435926749266014
-0.6608935424814646
true



 
  


  
bl  br