Stochastically choose one random machine distributed along their
    scores.
169546
def stochastic_choice(machines):
    """"""
    if len(machines) < 4:
        return random.choice(machines)

    r = random.random()
    if r < 0.5:
        return random.choice(machines[:len(machines)/4])
    elif r < 0.75:
        return random.choice(machines[:len(machines)/2])
    else:
        return random.choice(machines)
820180
private static void randomGaussian( Random rand , double sigma , int radius , Point2D_I32 pt ) {

		int x,y;

		while( true ) {
			x = (int)(rand.nextGaussian()*sigma);
			y = (int)(rand.nextGaussian()*sigma);
			if( Math.sqrt(x*x + y*y) < radius )
				break;
		}

		pt.set(x,y);
	}
1064654
def different_random_nt(self,nt):
    global nts
    
    return self._random.choice([x for x in nts if x != nt.upper()])
946009
def _random_x(self):
        """"""
        return (tuple(random.random() for _ in range(self.fmodel.dim_x)),)
1261899
def shuffle_sattolo(items):
    """"""
    _randrange = random.randrange
    for i in reversed(range(1, len(items))):
        j = _randrange(i)  # 0 <= j < i
        items[j], items[i] = items[i], items[j]
933674
def weighted_choice(lst):
    
    n = random.uniform(0, 1)
    for item, weight in lst:
        if n < weight:
            break
        n = n - weight
    return item
877883
def generator(self, random, args):
        """"""
        locations = [i for i in range(len(self.weights))]
        random.shuffle(locations)
        return locations
701546
def rand_elem(seq, n=None):
    """"""
    return map(random.choice, repeat(seq, n) if n is not None else repeat(seq))
357313
def random_partition(n, n_data):
    """"""
    all_idxs = np.arange(n_data)
    np.random.shuffle(all_idxs)
    idxs1 = all_idxs[:n]
    idxs2 = all_idxs[n:]
    return idxs1, idxs2
119546
def weighted_choice(self, probabilities, key):
        """"""

        total = sum(x[0] for x in probabilities)
        choice = total * self._random(key)

        for probability, option in probabilities:
            choice -= probability
            if choice <= 0:
                return option
35910
def _fully_random_weights(n_features, lam_scale, prng):
    """"""
    weights = np.zeros((n_features, n_features))
    n_off_diag = int((n_features ** 2 - n_features) / 2)
    weights[np.triu_indices(n_features, k=1)] = 0.1 * lam_scale * prng.randn(
        n_off_diag
    ) + (0.25 * lam_scale)
    weights[weights < 0] = 0
    weights = weights + weights.T
    return weights
612686
function createRandom(n, min, max) {
    let scale = max - min;
    let array = [];
    for (var i = 0; i < n; i++) {
        array[i] = (Math.random() * scale) + min;
    }
    return new Vector(array);
}
764858
def do_random(context, seq):
    """"""
    try:
        return random.choice(seq)
    except IndexError:
        return context.environment.undefined('No random item, sequence was empty.')
392534
def select(self, choice_scores):
        
        # choose algorithm using a bandit
        alg_scores = {}
        for algorithm, choices in self.by_algorithm.items():
            # only make arms for algorithms that have options
            if not set(choices) & set(choice_scores.keys()):
                continue
            # sum up lists to get a list of all the scores from any run of this
            # algorithm
            sublists = [choice_scores.get(c, []) for c in choices]
            alg_scores[algorithm] = sum(sublists, [])

        best_algorithm = self.bandit(alg_scores)

        # now use only the frozen sets from the chosen algorithm
        best_subset = self.by_algorithm[best_algorithm]
        normal_ucb1 = UCB1(choices=best_subset)
        return normal_ucb1.select(choice_scores)
288642
def random_weighted_choice(choices):
    
    choices, weights = zip(*choices.items())
    cumdist = list(accumulate(weights))
    x = random.random() * cumdist[-1]
    element = bisect.bisect(cumdist, x)
    return choices[element]
288193
function getRandomInt(min, max) {
    const minInt = Math.ceil(min);
    const maxInt = Math.floor(max);
    return Math.floor(Math.random() * (maxInt - minInt)) + minInt;
}
719934
def _random_helper(random, sampler, params, shape, dtype, ctx, out, kwargs):
    """"""
    if isinstance(params[0], NDArray):
        for i in params[1:]:
            assert isinstance(i, NDArray), \
                "Distribution parameters must all have the same type, but got " \
                "both %s and %s."%(type(params[0]), type(i))
        return sampler(*params, shape=shape, dtype=dtype, out=out, **kwargs)
    elif isinstance(params[0], numeric_types):
        if ctx is None:
            ctx = current_context()
        if shape is _Null and out is None:
            shape = 1
        for i in params[1:]:
            assert isinstance(i, numeric_types), \
                "Distribution parameters must all have the same type, but got " \
                "both %s and %s."%(type(params[0]), type(i))
        return random(*params, shape=shape, dtype=dtype, ctx=ctx, out=out, **kwargs)

    raise ValueError("Distribution parameters must be either NDArray or numbers, "
                     "but got %s."%type(params[0]))