Return a random normalized vector orthogonal to the given vector
559073
def random_orthonormal(normal):
    """"""
    u = normal_fns[np.argmin(np.fabs(normal))](normal)
    u /= np.linalg.norm(u)
    v = np.cross(normal, u)
    v /= np.linalg.norm(v)
    alpha = np.random.uniform(0.0, np.pi*2)
    return np.cos(alpha)*u + np.sin(alpha)*v
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);
}
1097307
def convert_random_uniform(node, **kwargs):
    
    name, input_nodes, attrs = get_inputs(node, kwargs)

    # Converting to float32
    low = float(attrs.get("low", 0))
    high = float(attrs.get("high", 1.0))
    shape = convert_string_to_list(attrs.get('shape', '[]'))
    dtype = onnx.mapping.NP_TYPE_TO_TENSOR_TYPE[np.dtype(attrs.get('dtype', 'float32'))]

    node = onnx.helper.make_node(
        'RandomUniform',
        input_nodes,
        [name],
        low=low,
        high=high,
        dtype=dtype,
        shape=shape,
        name=name
    )
    return [node]
208901
def randomArray2(size, bound):
    
    if type(size) == type(1):
        size = (size,)
    temp = Numeric.array( ndim(*size), thunk=lambda: random.gauss(0, 1)) * (2.0 * bound)
    return temp - bound
685534
private void randomPermute(int[] permute) {
        for (int i = 0; i < indexVectorSize; i++)
            permute[i] = i;
        for (int i = indexVectorSize - 1; i > 0; i--) {
            int w = (int) Math.floor(Math.random() * (i+1));
            int temp = permute[w];
            permute[w] = permute[i];
            permute[i] = permute[w];
        }
    }
823246
def random(cls):
        
        r1, r2, r3 = np.random.random(3)

        q1 = sqrt(1.0 - r1) * (sin(2 * pi * r2))
        q2 = sqrt(1.0 - r1) * (cos(2 * pi * r2))
        q3 = sqrt(r1)       * (sin(2 * pi * r3))
        q4 = sqrt(r1)       * (cos(2 * pi * r3))

        return cls(q1, q2, q3, q4)
116787
def rtruncated_normal(mu, tau, a=-np.inf, b=np.inf, size=None):
    

    sigma = 1. / np.sqrt(tau)
    na = utils.normcdf((a - mu) / sigma)
    nb = utils.normcdf((b - mu) / sigma)

    # Use the inverse CDF generation method.
    U = np.random.mtrand.uniform(size=size)
    q = U * nb + (1 - U) * na
    R = utils.invcdf(q)

    # Unnormalize
    return R * sigma + mu
483012
def fromvector(cls, v):
        """"""
        return cls(v.x, v.y, v.z)
303753
def vector_to_symmetric(v):
    ''''''
    np = len(v)
    N = (int(sqrt(1 + 8*np)) - 1)//2
    if N*(N+1)//2 != np:
        raise ValueError('Cannot convert vector to symmetric matrix')
    sym = ndarray((N,N))
    iterable = iter(v)
    for r in range(N):
        for c in range(r+1):
            sym[r,c] = sym[c,r] = iterable.next()
    return sym
610739
def randmatrix(m, n, random_seed=None):
    """"""
    val = np.sqrt(6.0 / (m + n))
    np.random.seed(random_seed)
    return np.random.uniform(-val, val, size=(m, n))
1026674
def unit_vector(vector, **kwargs):
    """"""
    # This also works for a dataframe with columns ['x', 'y', 'z']
    # However, the division operation is picky about the shapes
    # So, remember input vector shape, cast all up to 2d,
    # do the (ugly) conversion, then return unit in same shape as input
    # of course, the numpy-ized version of the input...
    vector = np.array(vector)
    out_shape = vector.shape
    vector = np.atleast_2d(vector)
    unit = vector / np.linalg.norm(vector, axis=1, **kwargs)[:, None]
    return unit.reshape(out_shape)
1100857
def random_unit(size=3):
    
    while True:
        result = np.random.normal(0, 1, size)
        length = np.linalg.norm(result)
        if length > 1e-3:
            return result/length
286623
def _norm_cmap(values, cmap, normalize, cm, vmin=None, vmax=None):
    

    mn = min(values) if vmin is None else vmin
    mx = max(values) if vmax is None else vmax
    norm = normalize(vmin=mn, vmax=mx)
    n_cmap = cm.ScalarMappable(norm=norm, cmap=cmap)
    return n_cmap
389530
def random_uniform(mesh, shape, **kwargs):
  
  shape = convert_to_shape(shape)
  return RandomOperation(mesh, shape, tf.random.uniform, **kwargs).outputs[0]
571925
function randomAxis(v) {
    v = v || new Vector3();

    v.x = Math$1.randFloatSpread(2.0);
    v.y = Math$1.randFloatSpread(2.0);
    v.z = Math$1.randFloatSpread(2.0);
    v.normalize();

    return v;
  }
310428
def normalize_vector(vector):
    
    v = np.divide(vector, np.linalg.norm(vector))
    return np.round(v, decimals=4)
707636
function (plane, rightvector) {
  if (arguments.length < 2) {
    // choose an arbitrary right hand vector, making sure it is somewhat orthogonal to the plane normal:
    rightvector = vec3.random(plane)
  } else {
    rightvector = rightvector
  }
  this.v = vec3.unit(vec3.cross(plane, rightvector))
  this.u = vec3.cross(this.v, plane)
  this.plane = plane
  this.planeorigin = vec3.scale(plane[3], plane)
}