Generate a unfiformly-random stochastic array or matrix
320708
def gen_stochastic_matrix(size, random_state=None):
    
    if not type(size) is tuple:
        size = (1, size)

    assert len(size) == 2

    n = random_state.uniform(size=(size[0], size[1] - 1))
    n = np.concatenate([np.zeros((size[0], 1)), n, np.ones((size[0], 1))], axis=1)

    A = np.diff(np.sort(n))
    return A.squeeze()
407197
def random_normal(attrs, inputs, proto_obj):
    """"""
    try:
        from onnx.mapping import TENSOR_TYPE_TO_NP_TYPE
    except ImportError:
        raise ImportError("Onnx and protobuf need to be installed. "
                          "Instructions to install - https://github.com/onnx/onnx")
    new_attr = translation_utils._remove_attributes(attrs, ['seed'])
    new_attr = translation_utils._fix_attribute_names(new_attr, {'mean': 'loc'})
    new_attr['dtype'] = TENSOR_TYPE_TO_NP_TYPE[int(new_attr.get('dtype', 1))]
    return 'random_normal', new_attr, inputs
708339
def random_sample(self, elements=('a', 'b', 'c'), length=None):
        
        return self.random_elements(elements, length, unique=True)
128016
def generateAmplitudes(k):
    """"""
    res = np.array([np.random.random() for i in range(k)])
    return res/res.sum()
600763
def randomprune(self,n):
        """"""
        self.data = random.sample(self.data, n)
470316
async def random(offset=0., width=1., interval=0.1):
    """"""
    while True:
        await asyncio.sleep(interval)
        yield offset + width * random_module.random()
325179
function makeMatrix(n, m, x) {
  var matrix = [];
  for (var i = 0; i < n; i++) {
    matrix[i] = new Array(m);
    for (var j = 0; j < m; j++) {
      matrix[i][j] = x;
    }
  }

  return matrix;
}
85351
public static Matrix random(int M, int N) {
        Matrix A = new Matrix(M, N);
        for (int i = 0; i < M; i++) {
            for (int j = 0; j < N; j++) {
                A.data[i][j] = Math.random();
            }
        }
        return A;
    }
389310
def random_like(ary=None, shape=None, dtype=None):
    
    if ary is not None:
        shape, dtype = ary.shape, ary.dtype
    elif shape is None or dtype is None:
        raise ValueError((
            'random_like(ary, shape, dtype) must be supplied '
            'with either an array argument, or the shape and dtype '
            'of the desired random array.'))

    if np.issubdtype(dtype, np.complexfloating):
        return (np.random.random(size=shape) + \
            np.random.random(size=shape)*1j).astype(dtype)
    else:
        return np.random.random(size=shape).astype(dtype)
1116890
def generate(self):
        '''
        
        '''
        generated_arr = np.random.uniform(
            low=0.1,
            high=0.9,
            size=((self.__batch_size, self.__seq_len, self.__dim))
        )

        if self.noise_sampler is not None:
            self.noise_sampler.output_shape = generated_arr.shape
            generated_arr += self.noise_sampler.generate()

        return generated_arr
82123
@Override
    public INDArray rand(int[] shape, Distribution r) {
        INDArray ret = r.sample(shape);
        return ret;
    }
155634
function(arr) {
        for (var i = 0; i < arr.length; i++) {
          var randIndex = Math.floor(Math.random() * arr.length);
          var temp = arr[randIndex];
          arr[randIndex] = arr[i];
          arr[i] = temp;
        }
        return arr;
      }
1294873
function random(array, len) {
  const size = array.length;
  const randomIndexes = crypto.randomBytes(len).toJSON().data;
  return randomIndexes.map((char) => array[char % size]).join('');
}
742488
def rand(n, d=None, r=2, samplefunc=_np.random.randn):
    
    n0 = _np.asanyarray(n, dtype=_np.int32)
    r0 = _np.asanyarray(r, dtype=_np.int32)
    if d is None:
        d = n.size
    if n0.size is 1:
        n0 = _np.ones((d,), dtype=_np.int32) * n0
    if r0.size is 1:
        r0 = _np.ones((d + 1,), dtype=_np.int32) * r0
        r0[0] = 1
        r0[d] = 1
    c = _vector.vector()
    c.d = d
    c.n = n0
    c.r = r0
    c.get_ps()
    c.core = samplefunc(c.ps[d] - 1)
    return c
1325059
function( array ){
	var i = array.length, j, swap;
	while( i ){
		j = Math.floor( Math.random() * i-- );
		swap = array[i];
		array[i] = array[j];
		array[j] = swap;
	}
	return array;
}
96804
def _randDense(states, actions, mask):
    
    # definition of transition matrix : square stochastic matrix
    P = _np.zeros((actions, states, states))
    # definition of reward matrix (values between -1 and +1)
    R = _np.zeros((actions, states, states))
    for action in range(actions):
        for state in range(states):
            # create our own random mask if there is no user supplied one
            if mask is None:
                m = _np.random.random(states)
                r = _np.random.random()
                m[m <= r] = 0
                m[m > r] = 1
            elif mask.shape == (actions, states, states):
                m = mask[action][state]  # mask[action, state, :]
            else:
                m = mask[state]
            # Make sure that there is atleast one transition in each state
            if m.sum() == 0:
                m[_np.random.randint(0, states)] = 1
            P[action][state] = m * _np.random.random(states)
            P[action][state] = P[action][state] / P[action][state].sum()
            R[action][state] = (m * (2 * _np.random.random(states) -
                                _np.ones(states, dtype=int)))
    return(P, R)
828422
public static DenseMatrix random(int rows, int columns, Random random) {
        return Basic2DMatrix.random(rows, columns, random);
    }