Java Random gaussianInt(Random random, int min, int max)

Here you can find the source of gaussianInt(Random random, int min, int max)

Description

gaussian Int

License

Open Source License

Declaration

public static int gaussianInt(Random random, int min, int max) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.*;

public class Main {
    private static final double GAUSSIAN_LIMIT = 3.0d;

    public static int gaussianInt(Random random, int min, int max) {
        if (max < min) {
            throw new IllegalArgumentException("max < min");
        }//from ww  w  . j  a  v  a  2s . c o m
        double det = (random.nextGaussian() + GAUSSIAN_LIMIT) / GAUSSIAN_LIMIT / 2.0d;
        return min + (int) (det * (max - min));
    }
}

Related

  1. createRandomStr(int digit)
  2. decimal_random()
  3. equalsRandomIterable(List a, List bl)
  4. extractRandomObject(Collection c)
  5. extractRandomVector(Collection c, int newSize)
  6. generateRandom(byte[] byteArray)
  7. generateRandom(int length, int type)
  8. generateRandom(Integer bitNum)
  9. generateRandomIntegerId()