Draw random samples of the hyperparameters.
        
        Parameters
        ----------
        size : None, int or array-like, optional
            The number/shape of samples to draw. If None, only one sample is
            returned. Default is None.
168115
def random_draw(self, size=None):
        
        return scipy.asarray([scipy.stats.gamma.rvs(a, loc=0, scale=1.0 / b, size=size) for a, b in zip(self.a, self.b)])
740212
protected void getBatch(int batchSize){

//      if (numCalls == 0) {
//        for (int i = 0; i < 1538*\15; i++) {
//          randGenerator.nextInt(this.dataDimension());
//        }
//      }
//      numCalls++;

    if (thisBatch == null || thisBatch.length != batchSize){
      thisBatch = new int[batchSize];
    }

    //-----------------------------
    //RANDOM WITH REPLACEMENT
    //-----------------------------
    if (sampleMethod.equals(SamplingMethod.RandomWithReplacement)){
      for(int i = 0; i<batchSize;i++){
        thisBatch[i] = randGenerator.nextInt(this.dataDimension());        //Just generate a random index
//        System.err.println("numCalls = "+(numCalls++));
      }
      //-----------------------------
      //ORDERED
      //-----------------------------
    }else if(sampleMethod.equals(SamplingMethod.Ordered)){
      for(int i = 0; i<batchSize;i++){
        thisBatch[i] = (curElement + i) % this.dataDimension() ;          //Take the next batchSize points in order
      }
      curElement = (curElement + batchSize) % this.dataDimension();       //watch out for overflow

      //-----------------------------
      //RANDOM WITHOUT REPLACEMENT
      //-----------------------------
    }else if(sampleMethod.equals(SamplingMethod.RandomWithoutReplacement)){
      //Declare the indices array if needed.
      if (allIndices == null || allIndices.size()!= this.dataDimension()){

        allIndices = new ArrayList<Integer>();
        for(int i=0;i<this.dataDimension();i++){
          allIndices.add(i);
        }
        Collections.shuffle(allIndices,randGenerator);
      }

      for(int i = 0; i<batchSize;i++){
        thisBatch[i] = allIndices.get((curElement + i) % allIndices.size());  //Grab the next batchSize indices
      }

      if (curElement + batchSize > this.dataDimension()){
        Collections.shuffle(Arrays.asList(allIndices),randGenerator);                   //Shuffle if we got to the end of the list
      }

      //watch out for overflow
      curElement = (curElement + batchSize) % allIndices.size();          //Rollover


    }else{
      System.err.println("NO SAMPLING METHOD SELECTED");
      System.exit(1);
    }


  }
113018
public void setup( int numSamples , int sampleSize ) {
        mean = new double[ sampleSize ];
        A.reshape(numSamples,sampleSize,false);
        sampleIndex = 0;
        numComponents = -1;
    }
157046
def discrete_random_draw(data, nb=1):
    ''' '''
    data = np.array(data)
    if not data.any():
        data = np.ones_like(data)
    data = data/data.sum()
    xk = np.arange(len(data))
    custm = stats.rv_discrete(name='custm', values=(xk, data))
    return custm.rvs(size=nb)
985675
def _init_parameters_random(self, X_bin):
        

        _, n_features = X_bin.shape

        # The parameter class_log_prior_ has shape (2,). The values represent
        # 'match' and 'non-match'.
        rand_vals = np.random.rand(2)
        class_prior = rand_vals / np.sum(rand_vals)

        # make empty array of feature log probs
        # dimensions 2xn_features
        feature_prob = np.zeros((2, n_features))

        feat_i = 0

        for i, bin in enumerate(self._binarizers):

            bin_len = bin.classes_.shape[0]

            rand_vals_0 = np.random.rand(bin_len)
            feature_prob[0, feat_i:feat_i + bin_len] = \
                rand_vals_0 / np.sum(rand_vals_0)

            rand_vals_1 = np.random.rand(bin_len)
            feature_prob[1, feat_i:feat_i + bin_len] = \
                rand_vals_1 / np.sum(rand_vals_1)

            feat_i += bin_len

        return np.log(class_prior), np.log(feature_prob)
980406
def sample_radius(self, n):
        
        edge = self.edge if self.edge<20*self.extension else 20*self.extension
        radius = np.linspace(0, edge, 1.e5)
        pdf = self._pdf(radius) * np.sin(np.radians(radius))
        cdf = np.cumsum(pdf)
        cdf /= cdf[-1]
        fn = scipy.interpolate.interp1d(cdf, list(range(0, len(cdf))))
        index = np.floor(fn(np.random.uniform(size=n))).astype(int)
        return radius[index]
311907
def generate_samples(label, num_splits, sampler):
    
    def listify(x):
        return x if isinstance(x, list) else [x]
    label_splits = listify(label.split(num_splits, axis=0))
    prob_samples = []
    prob_targets = []
    samples = []
    for label_split in label_splits:
        label_split_2d = label_split.reshape((-1,1))
        sampled_value = sampler.draw(label_split_2d)
        sampled_classes, exp_cnt_true, exp_cnt_sampled = sampled_value
        samples.append(sampled_classes.astype(np.float32))
        prob_targets.append(exp_cnt_true.astype(np.float32).reshape((-1,1)))
        prob_samples.append(exp_cnt_sampled.astype(np.float32))
    return samples, prob_samples, prob_targets
219587
def random_draw(self, size=None):
        
        return scipy.asarray([numpy.random.uniform(low=b[0], high=b[1], size=size) for b in self.bounds])
947329
def labeled_uniform_sample(self, sample_size, replace=True):
        
        if replace:
            samples = [
                random.choice(self.get_labeled_entries())
                for _ in range(sample_size)
            ]
        else:
            samples = random.sample(self.get_labeled_entries(), sample_size)
        return Dataset(*zip(*samples))
52361
def random_samples(self, n):
        
        samples = self.samples
        inds = rand.randint(len(samples),size=int(n))

        newsamples = samples.iloc[inds]
        newsamples.reset_index(inplace=True)
        return newsamples
773564
def get_samples_with_constraints(self, init_points_count):
        
        samples = np.empty((0, self.space.dimensionality))

        while samples.shape[0] < init_points_count:
            domain_samples = self.get_samples_without_constraints(init_points_count)
            valid_indices = (self.space.indicator_constraints(domain_samples) == 1).flatten()
            if sum(valid_indices) > 0:
                valid_samples = domain_samples[valid_indices,:]
                samples = np.vstack((samples,valid_samples))

        return samples[0:init_points_count,:]
485857
def _sampleFromFaces(self):
    
    coordinates = [random.uniform(-1, 1) * dim / 2. for dim in self.dimensions]
    dim = random.choice(range(self.dimension))
    coordinates[dim] = self.dimensions[dim] / 2. * random.choice([-1, 1])
    return coordinates
1223617
def _sampleFromVertices(self):
    
    coordinates = [
      self.dimensions[0] / 2. * random.choice([-1, 1]),
      self.dimensions[1] / 2. * random.choice([-1, 1]),
      self.dimensions[2] / 2. * random.choice([-1, 1]),
    ]
    return coordinates
391389
def randomArray(size, bound):
    
    if type(size) == type(1):
        size = (size,)
    temp = Numeric.array( ndim(*size) ) * (2.0 * bound)
    return temp - bound
747048
public static MutableDoubleTuple createRandomGaussian(
        int size, Random random)
    {
       MutableDoubleTuple t = create(size);
       randomizeGaussian(t, random);
       return t;
    }
664990
def rvs(self, size=1):
        

        # create output FieldArray
        out = record.FieldArray(size, dtype=[(arg, float)
                                    for arg in self.variable_args])

        # loop until enough samples accepted
        n = 0
        while n < size:

            # draw samples
            samples = {}
            for dist in self.distributions:
                draw = dist.rvs(1)
                for param in dist.params:
                    samples[param] = draw[param][0]
            vals = numpy.array([samples[arg] for arg in self.variable_args])

            # determine if all parameter values are in prior space
            # if they are then add to output
            if self(**dict(zip(self.variable_args, vals))) > -numpy.inf:
                out[n] = vals
                n += 1

        return out
835894
def sample(self, nsamples=100, seed=None):
        
        if nsamples < 1:
            raise ValueError("Number of samples must be larger than 0, got '%g'" % nsamples)

        if seed is None:
            seed = random.randint(0, 2 ** 32)

        if self.mode == 'spark':
            result = asarray(self.values.tordd().values().takeSample(False, nsamples, seed))

        else:
            inds = [int(k) for k in random.rand(nsamples) * self.shape[0]]
            result = asarray([self.values[i] for i in inds])

        return self._constructor(result)