Return a vector of random scales
554591
def _getScalesRand(self):
        
        if self.P>1:
            scales = []
            for term_i in range(self.n_terms):
                _scales = SP.randn(self.diag[term_i].shape[0])
                if self.offset[term_i]>0:
                    _scales = SP.concatenate((_scales,SP.array([SP.sqrt(self.offset[term_i])])))
                scales.append(_scales)
            scales = SP.concatenate(scales)
        else:
            scales=SP.randn(self.vd.getNumberScales())

        return scales
29523
def returnMatches(kw, kv, n, theta, inputScaling=1.0):
  
  # How many weight vectors and input vectors to generate at a time
  m1 = 4
  m2 = 1000

  weights = getSparseTensor(kw, n, m1, fixedRange=1.0 / kw)

  # Initialize random input vectors using given scaling and see how many match
  inputVectors = getSparseTensor(kv, n, m2,
                                 onlyPositive=True,
                                 fixedRange= 2*inputScaling / kw,
                                 )
  dot = inputVectors.matmul(weights.t())
  numMatches = ((dot >= theta).sum()).item()
  pctMatches = numMatches / float(m1*m2)

  return pctMatches, numMatches, m1*m2
747260
def rlognormal(mu, tau, size=None):
    

    return np.random.lognormal(mu, np.sqrt(1. / tau), size)
1353280
def generate(self):
        """"""

        ts=self.generate_tobs()
        noise=self.generate_noise(ts)
        
        rvs=[]
        for t,n in zip(ts, noise):
            rvs.append(n + np.sum(rv.rv_model(t, self.params), axis=0))

        return ts,rvs
741590
def Kdiag(self, X):
        """"""
        K_ff = np.ones(X.shape[0])
        for i,x in enumerate(X):
            for il,l in enumerate(self.lengthscale):
                idx = il*2
                K_ff[i] *= self.k_ff(x[idx],x[idx],l)
        return K_ff * self.variances[0]
329934
def rnormal(mu, tau, size=None):
    
    return np.random.normal(mu, 1. / np.sqrt(tau), size)
1087219
def rlogistic(mu, tau, size=None):
    

    u = np.random.random(size)
    return mu + np.log(u / (1 - u)) / tau
647199
def init_nn_params(scale, layer_sizes, rs=npr.RandomState(0)):
    """"""
    return [(rs.randn(insize, outsize) * scale,   # weight matrix
             rs.randn(outsize) * scale)           # bias vector
            for insize, outsize in zip(layer_sizes[:-1], layer_sizes[1:])]
1140499
def unit_vector(x):
    """"""
    y = np.array(x, dtype='float')
    return y/norm(y)
1336549
def random_draw(self, size=None):
        
        return scipy.asarray([scipy.stats.norm.rvs(loc=m, scale=s, size=size) for s, m in zip(self.sigma, self.mu)])
34772
def _next_sample_index(self):
        """"""
        return self.rng.choice(self.n_active,
                               p=(self.stream_weights_ /
                                  self.weight_norm_))
467761
def _get_tau_vector(self, tau_mean, tau_std, imt_list):
        
        self.magnitude_limits = MAG_LIMS_KEYS[self.tau_model]["mag"]
        self.tau_keys = MAG_LIMS_KEYS[self.tau_model]["keys"]
        t_bar = {}
        t_std = {}
        for imt in imt_list:
            t_bar[imt] = []
            t_std[imt] = []
            for mag, key in zip(self.magnitude_limits, self.tau_keys):
                t_bar[imt].append(
                    TAU_EXECUTION[self.tau_model](imt, mag, tau_mean))
                t_std[imt].append(
                    TAU_EXECUTION[self.tau_model](imt, mag, tau_std))
        return t_bar, t_std
1214940
def generate_samples(self):
        """"""
        filenames = glob_all(self.args.random_data_folder, '*.wav')
        shuffle(filenames)
        while True:
            for fn in filenames:
                for x, y in self.vectors_from_fn(fn):
                    yield x, y
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;
  }
1000127
def random_sample(self, num_samples, df=None, replace=False, weights=None, random_state=100, axis='row'):
    '''
    
    '''

    if df is None:
      df = self.dat_to_df()

    if axis == 'row':
      axis = 0
    if axis == 'col':
      axis = 1

    df = self.export_df()
    df = df.sample(n=num_samples, replace=replace, weights=weights, random_state=random_state,  axis=axis)

    self.load_df(df)
936564
function scale(a, s){
    return Vector2(a.x * s, a.y * s);
  }
1084387
def random_combination(iterable, r):
    ""
    pool = tuple(iterable)
    n = len(pool)
    indices = sorted(random.sample(xrange(n), r))
    return tuple(pool[i] for i in indices)