Calculates "chance" out of "max chances". Example: 1 chance out of 3 chances
(or 33.3%)

@param chances    a chance proportional to maxChances.
@param maxChances a maximum number of chances
@return random boolean value.
965060
public static boolean chance(float chances, float maxChances) {
		chances = chances >= 0 ? chances : 0;
		maxChances = maxChances >= 0 ? maxChances : 0;
		if (chances == 0 && maxChances == 0)
			return false;

		maxChances = Math.max(maxChances, chances);
		double start = (maxChances - chances) / 2;
		double end = start + chances;
		double hit = _random.nextDouble() * maxChances;
		return hit >= start && hit <= end;
	}
140057
public String randomName(String prefix, int maxLen) {
        prefix = prefix.toLowerCase();
        int minRandomnessLength = 5;
        if (maxLen <= minRandomnessLength) {
            return randomString(maxLen);
        }

        if (maxLen < prefix.length() + minRandomnessLength) {
            return randomString(maxLen);
        }

        String minRandomString = String.format("%05d", Math.abs(RANDOM.nextInt() % 100000));

        if (maxLen <= prefix.length() + randName.length() + minRandomnessLength) {
            String str = prefix + minRandomString;
            return str + randomString((maxLen - str.length()) / 2);
        }

        String str = prefix + randName + minRandomString;
        return str + randomString((maxLen - str.length()) / 2);
    }
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;
    }
683056
@Override
    public DataSet sample(int numSamples, org.nd4j.linalg.api.rng.Random rng) {
        return sample(numSamples, rng, false);
    }
705279
static int getRandomInt(int min, int max, Random random) {
		// Use random.nextInt as it guarantees a uniform distribution
		int maxForRandom = max - min + 1;
		return random.nextInt(maxForRandom) + min;
	}
532169
public static int maxBucketsPerElement(long numElements)
    {
        numElements = Math.max(1, numElements);
        double v = (Long.MAX_VALUE - EXCESS) / (double)numElements;
        if (v < 1.0)
        {
            throw new UnsupportedOperationException("Cannot compute probabilities for " + numElements + " elements.");
        }
        return Math.min(BloomCalculations.probs.length - 1, (int)v);
    }
890284
public static int getMaxValue (int[] values)
    {
        int max = Integer.MIN_VALUE;
        int vcount = (values == null) ? 0 : values.length;
        for (int ii = 0; ii < vcount; ii++) {
            if (values[ii] > max) {
                // new max
                max = values[ii];
            }
        }
        return max;
    }
386863
@Override
    public DataSet sample(int numSamples, org.nd4j.linalg.api.rng.Random rng, boolean withReplacement) {
        Set<Integer> added = new HashSet<>();
        List<DataSet> toMerge = new ArrayList<>();
        boolean terminate = false;
        for (int i = 0; i < numSamples && !terminate; i++) {
            int picked = rng.nextInt(numExamples());
            if (!withReplacement) {
                while (added.contains(picked)) {
                    picked = rng.nextInt(numExamples());
                    if(added.size() == numExamples()){
                        terminate = true;
                        break;
                    }
                }
            }
            added.add(picked);
            toMerge.add(get(picked));
        }
        return DataSet.merge(toMerge);
    }
601631
public static <T> T randomOne(T... values) {
		return (T) values[RANDOM.nextInt(values.length)];
	}
501386
@Pure
	public static int max(int... values) {
		if (values == null || values.length == 0) {
			return 0;
		}
		int max = values[0];
		for (final int v : values) {
			if (v > max) {
				max = v;
			}
		}
		return max;
	}
391050
@Pure
	public static double max(double... values) {
		if (values == null || values.length == 0) {
			return Double.NaN;
		}
		double max = values[0];
		for (final double v : values) {
			if (v > max) {
				max = v;
			}
		}
		return max;
	}
307048
protected int getMaxTries() throws ActivityException {
        try {
            String v = getAttributeValueSmart(PROP_MAX_TRIES);
            int ret = StringHelper.getInteger(v, 1);
            return ret<1?1:ret;
        }
        catch (PropertyException ex) {
            throw new ActivityException(ex.getMessage(), ex);
        }
    }
959237
public static int random(final int min, final int max) {
        return min + new java.security.SecureRandom().nextInt(max - min + 1);
    }
756618
function luckio(chance) {
  var min = 1;
  var max = math.maxRange(chance);
  var luckyNumber = math.randomNumber(min, max);

  return function() {
    if (math.randomNumber(min, max) === luckyNumber) return true;
    return false;
  }
}
615859
public static int getRandomInteger(int min, int max) {
		Random r = new Random();
		return r.nextInt(max - min + 1) + min;
	}
1346307
public float max(float... values) {
        float max = Float.MIN_VALUE;
        for (int i = 0; i < values.length; i++) {
            if (i == 0 || values[i] > max) {
                max = values[i];
            }
        }
        
        return max;
    }
95930
public static int randomIntGreaterThan(int minExclusive) {
    checkArgument(
        minExclusive < Integer.MAX_VALUE, "Cannot produce int greater than %s", Integer.MAX_VALUE);
    return randomInt(minExclusive + 1, Integer.MAX_VALUE);
  }