Generates a new random {@code TraceId}.

@param random the random number generator.
@return a new valid {@code TraceId}.
@since 0.5
514253
public static TraceId generateRandomId(Random random) {
    long idHi;
    long idLo;
    do {
      idHi = random.nextLong();
      idLo = random.nextLong();
    } while (idHi == INVALID_ID && idLo == INVALID_ID);
    return new TraceId(idHi, idLo);
  }
689984
@Override
	public RandomVariable add(RandomVariable randomVariable) {
		if(randomVariable.getTypePriority() > this.getTypePriority()) {
			// Check type priority
			return randomVariable.add(this);
		}

		return new RandomVariableDifferentiableAAD(
				getValues().add(randomVariable.getValues()),
				Arrays.asList(this.getOperatorTreeNode(), OperatorTreeNode.of(randomVariable)),
				Arrays.asList(null /* this.getValues() */, null /* randomVariable.getValues() */),		// For ADD we do not need all arguments to evaluate the differential
				null,
				OperatorType.ADD,
				getFactory(),
				typePriorityDefault);
	}
477745
private static String generateRandomAutomaton(Random random) throws IOException {

        final Automaton<?, Integer, ?> automaton;

        if (random.nextBoolean()) {
            automaton = RandomAutomata.randomDFA(random, AUTOMATON_SIZE, INPUT_ALPHABET);
        } else {
            automaton = RandomAutomata.randomMealy(random, AUTOMATON_SIZE, INPUT_ALPHABET, OUTPUT_ALPHABET);
        }

        final StringWriter writer = new StringWriter();

        GraphDOT.write(automaton, INPUT_ALPHABET, writer);

        return writer.toString();
    }
696564
public static UUID fastUUID() {
		ThreadLocalRandom random = ThreadLocalRandom.current();
		return new UUID(random.nextLong(), random.nextLong());
	}
59025
@Override
    public ListT<W,T> shuffle(final Random random) {

        return (ListT<W,T>) FoldableTransformerSeq.super.shuffle(random);
    }
433886
public static Token generate(final Random random, final Key key, final byte[] payload) {
        final IvParameterSpec initializationVector = generateInitializationVector(random);
        final byte[] cipherText = key.encrypt(payload, initializationVector);
        final Instant timestamp = Instant.now();
        final byte[] hmac = key.sign(supportedVersion, timestamp, initializationVector, cipherText);
        return new Token(supportedVersion, timestamp, initializationVector, cipherText, hmac);
    }
813623
public T[] generateRandomCandidate(Random rng)
    {
        T[] candidate = elements.clone();
        List<T> list = Arrays.asList(candidate);
        Collections.shuffle(list, rng);
        return list.toArray(candidate);
    }
303553
public static long random(final long randomStart)
    {
        long randomValue = randomStart;
        randomValue ^= (randomValue << 21);
        randomValue ^= (randomValue >>> 35);
        randomValue ^= (randomValue << 4);

        return randomValue;
    }
91880
public static Key generateKey(final Random random) {
        final byte[] signingKey = new byte[signingKeyBytes];
        random.nextBytes(signingKey);
        final byte[] encryptionKey = new byte[encryptionKeyBytes];
        random.nextBytes(encryptionKey);
        return new Key(signingKey, encryptionKey);
    }
129277
public String generateRandomToken(int length) {
        final char[] token = new char[length];

        for (int i = 0; i < length; i++) {
            final int tokenIndex = random.nextInt(this.tokenChars.length);
            token[i] = tokenChars[tokenIndex];
        }

        return new String(token);
    }
694323
public Channel.ID createChannel()
	{
		final int num = getNextPathNum();
		return new Channel.ID(this.paths[num], num, this.random);
	}
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;
	}
1372997
public static final String generateHex(final Random random, final int characters)
	{
		if (characters < 1)
			throw new IllegalArgumentException("characters must be >= 1");

		final char[] str = new char[characters];

		for (int i = 0; i < characters; i++)
		{
			str[i] = hex[random.nextInt(16)];
		}

		return new String(str);
	}
126338
@SuppressWarnings("unchecked")
    public static <T> Randomizer<T> asRandomizer(final Supplier<T> supplier) {

        class RandomizerProxy implements InvocationHandler {

            private final Supplier<?> target;

            private RandomizerProxy(final Supplier<?> target) {
                this.target = target;
            }

            @Override
            public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
                if ("getRandomValue".equals(method.getName())) {
                    Method getMethod = target.getClass().getMethod("get");
                    getMethod.setAccessible(true);
                    return getMethod.invoke(target);
                }
                return null;
            }
        }

        return (Randomizer<T>) Proxy.newProxyInstance(
                Randomizer.class.getClassLoader(),
                new Class[]{Randomizer.class},
                new RandomizerProxy(supplier));
    }
974601
public static DBIDVar randomSample(DBIDs ids, RandomFactory random) {
    return randomSample(ids, random.getSingleThreadedRandom());
  }
759839
public static UUID randomUUID(boolean isSecure) {
		final Random ng = isSecure ? Holder.numberGenerator : RandomUtil.getRandom();

		byte[] randomBytes = new byte[16];
		ng.nextBytes(randomBytes);
		randomBytes[6] &= 0x0f; /* clear version */
		randomBytes[6] |= 0x40; /* set to version 4 */
		randomBytes[8] &= 0x3f; /* clear variant */
		randomBytes[8] |= 0x80; /* set to IETF variant */
		return new UUID(randomBytes);
	}
8944
public static NumberExpression<Double> random(int seed) {
        return Expressions.numberOperation(Double.class, MathOps.RANDOM2, ConstantImpl.create(seed));
    }