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

Discrete Uniform 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 DiscreteUniformGenerator class.

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

import java.util.Random;

import org.uncommons.maths.random.DiscreteUniformGenerator;

public class DiscreteUniformGeneratorTest {

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

    DiscreteUniformGenerator rand = 
      new DiscreteUniformGenerator(2040new Random());

    for (int i = ; i < 10 ; i ++) {
      System.out.println(rand.nextValue());
    }
    
  }

}
   

It gives the following output,
29
30
39
31
21
33
37
22
23
32



 
  


  
bl  br