Returns an effectively unlimited stream of pseudorandom {@code int}
values.

<p>A pseudorandom {@code int} value is generated as if it's the result of
calling the method {@link Random#nextInt()}.

@return a stream of pseudorandom {@code int} values
493862
@NotNull
    public IntStream ints() {
        return IntStream.generate(new IntSupplier() {
            @Override
            public int getAsInt() {
                return random.nextInt();
            }
        });
    }
1299282
public static int[] generateRandomNumber(int begin, int end, int size) {
		if (begin > end) {
			int temp = begin;
			begin = end;
			end = temp;
		}
		// 加入逻辑判断，确保begin<end并且size不能大于该表示范围
		if ((end - begin) < size) {
			throw new UtilException("Size is larger than range between begin and end!");
		}
		// 种子你可以随意生成，但不能重复
		int[] seed = new int[end - begin];

		for (int i = begin; i < end; i++) {
			seed[i - begin] = i;
		}
		int[] ranArr = new int[size];
		Random ran = new Random();
		// 数量你可以自己定义。
		for (int i = 0; i < size; i++) {
			// 得到一个位置
			int j = ran.nextInt(seed.length - i);
			// 得到那个位置的数值
			ranArr[i] = seed[j];
			// 将最后一个未用的数字放到这里
			seed[j] = seed[seed.length - 1 - i];
		}
		return ranArr;
	}
453262
public static IntStream buildRandomIntStream(int streamSize, Random random,
            int exclusiveBound) {
        return buildRandomIntStream(streamSize,
                () -> random.nextInt(exclusiveBound));
    }
1204902
public IntStream stream()
    {
        IntStream.Builder builder = IntStream.builder();
        forEach(builder);
        return builder.build();
    }
1140597
public static Stream<Integer> box(final int[] integers) {
        return new FixedSizeStream<>(integers.length, new Func1<Integer, Integer>() {
            @Override
            public Integer call(Integer index) {
                return integers[index];
            }
        });
    }
119108
@Override
    public final Integer generate(final Integer max) {
        final Integer result;

        if (max < LOWER_LIMIT) {
            LOGGER.warn(
                    "Received {} as maximum value, but this is lower than {}",
                    max, LOWER_LIMIT);
            result = 0;
        } else {
            result = random.nextInt(Math.abs(LOWER_LIMIT - max) + 1)
                    + LOWER_LIMIT;
        }

        return result;
    }
703490
public static Tuple2<Double, Double> getRandomGeographicalLocation() {
        return new Tuple2<>(
            (double) (RandomHelper.randWithConfiguredSeed().nextInt(999) + 1) / 100,
            (double) (RandomHelper.randWithConfiguredSeed().nextInt(999) + 1) / 100);
    }
706643
protected synchronized Random getRandom() {
        if (this.random == null) {
            try {
                Class clazz = Class.forName(randomClass);
                this.random = (Random) clazz.newInstance();
                long seed = System.currentTimeMillis();
                char[] entropy = getEntropy().toCharArray();
                for (int i = 0; i < entropy.length; i++) {
                    long update = ((byte) entropy[i]) << ((i % 8) * 8);
                    seed ^= update;
                }
                this.random.setSeed(seed);
            } catch (Exception e) {
                this.random = new java.util.Random();
            }
        }
        return (this.random);
    }
782985
public Double nextValue()
    {
        double u;
        do
        {
            // Get a uniformly-distributed random double between
            // zero (inclusive) and 1 (exclusive)
            u = rng.nextDouble();
        } while (u == 0d); // Reject zero, u must be positive for this to work.
        return (-Math.log(u)) / rate.nextValue();
    }
813623
public T[] generateRandomCandidate(Random rng)
    {
        T[] candidate = elements.clone();
        List<T> list = Arrays.asList(candidate);
        Collections.shuffle(list, rng);
        return list.toArray(candidate);
    }
1050892
public E getNextValue() throws ValueGenerationException{
		if(!isValid())
			throw new ValueGenerationException("Cannot provide elements in invalid state.");
		Double random = rand.nextDouble();
		for(int i=0; i<limits.size(); i++)
			if(random <= limits.get(i)){
				return keys.get(i);
			}
		return null;
	}
1150939
public static void foreachRandomInt(int streamSize, int exclusiveBound,
            IntConsumer eachRandomIntConsumer) {
        foreachRandomInt(streamSize, new Random(), exclusiveBound,
                eachRandomIntConsumer);
    }
1300159
public static int randomIntLessThan(int maxExclusive) {
    checkArgument(
        maxExclusive > Integer.MIN_VALUE, "Cannot produce int less than %s", Integer.MIN_VALUE);
    return randomInt(Integer.MIN_VALUE, maxExclusive);
  }
283718
public static Random getRandom()
  {
    if (_isTest) {
      return _testRandom;
    }

    Random random = _freeRandomList.allocate();

    if (random == null) {
      random = new SecureRandom();
    }

    return random;
  }
287566
@Override
    public String getRandomValue() {
        StringBuilder buf = new StringBuilder();
        while (buf.length() < expectedSizeOfRandomValues) {
            int index = getIndexIntoWordArray();
            buf.append(words[index]);
            buf.append(" ");
        }

        return buf.toString().substring(0, expectedSizeOfRandomValues);
    }
456672
@Override
    public final IntStream limit(long maxSize) {
        if (maxSize < 0)
            throw new IllegalArgumentException(Long.toString(maxSize));
        return SliceOps.makeInt(this, 0, maxSize);
    }
944123
public static BigDecimal randomBigDecimal(BigDecimal limit) {
		return NumberUtil.toBigDecimal(getRandom().nextDouble(limit.doubleValue()));
	}