Draw a single random sample.

@param ids IDs to draw from
@param random Random value
@return Random ID
974601
public static DBIDVar randomSample(DBIDs ids, RandomFactory random) {
    return randomSample(ids, random.getSingleThreadedRandom());
  }
1061893
public static Integer[] transformToInt(final String[] ids) {
    if (ids == null) return new Integer[0];
    Integer[] idsOfInteger = new Integer[ids.length];
    for (int i = 0; i < ids.length; i++) {
      idsOfInteger[i] = new Integer(ids[i]);
    }
    return idsOfInteger;
  }
672205
public void setHtmlElementId(String id) {
		htmlElementId = id;
		mapWidget.setHtmlElement(DOM.getElementById(id));
		mapWidget.draw();
	}
1353440
public static Basic2DMatrix random(int rows, int columns, Random random) {
        double[][] array = new double[rows][columns];

        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < columns; j++) {
                array[i][j] = random.nextDouble();
            }
        }

        return new Basic2DMatrix(array);
    }
934682
public static ModifiableDBIDs randomSample(DBIDs source, int k, Random random) {
    if(k < 0 || k > source.size()) {
      throw new IllegalArgumentException("Illegal value for size of random sample: " + k + " > " + source.size() + " or < 0");
    }
    // Fast, and we're single-threaded here anyway.
    random = (random != null) ? random : new FastNonThreadsafeRandom();

    // TODO: better balancing for different sizes
    // Two methods: constructive vs. destructive
    if(k < source.size() >> 2) {
      ArrayDBIDs aids = DBIDUtil.ensureArray(source);
      DBIDArrayIter iter = aids.iter();
      final int size = aids.size();
      HashSetModifiableDBIDs sample = DBIDUtil.newHashSet(k);
      while(sample.size() < k) {
        sample.add(iter.seek(random.nextInt(size)));
      }
      return sample;
    }
    else {
      ArrayModifiableDBIDs sample = DBIDUtil.newArray(source);
      randomShuffle(sample, random, k);
      // Delete trailing elements
      for(int i = sample.size() - 1; i >= k; i--) {
        sample.remove(i);
      }
      return sample;
    }
  }
1184462
public void setIds(java.util.Collection<String> ids) {
        if (ids == null) {
            this.ids = null;
            return;
        }

        this.ids = new java.util.ArrayList<String>(ids);
    }
484156
private static Stormtrooper randomTrooper(String id) {
        String planet = planetsList[RANDOM.nextInt(planetsList.length)];
        String species = speciesList[RANDOM.nextInt(speciesList.length)];
        String type = trooperTypes[RANDOM.nextInt(trooperTypes.length)];

        return new Stormtrooper(id, planet, species, type);
    }
496962
public static ColumnMajorSparseMatrix random(int rows, int columns, double density, Random random) {
        return CCSMatrix.random(rows, columns, density, random);
    }
1037522
public static Matrix random(int rows, int columns, Random random) {
        return DenseMatrix.random(rows, columns, random);
    }
1175785
@Override
    public DataSet sample(int numSamples, boolean withReplacement) {
        return sample(numSamples, Nd4j.getRandom(), withReplacement);
    }
514253
public static TraceId generateRandomId(Random random) {
    long idHi;
    long idLo;
    do {
      idHi = random.nextLong();
      idLo = random.nextLong();
    } while (idHi == INVALID_ID && idLo == INVALID_ID);
    return new TraceId(idHi, idLo);
  }
628060
public <T> T randomElement(List<T> elements) {
		return elements.get(randomBetween(0, elements.size() - 1));
	}
813623
public T[] generateRandomCandidate(Random rng)
    {
        T[] candidate = elements.clone();
        List<T> list = Arrays.asList(candidate);
        Collections.shuffle(list, rng);
        return list.toArray(candidate);
    }
835477
def generate_random_id(size=6, chars=string.ascii_uppercase + string.digits):
    """"""
    return "".join(random.choice(chars) for x in range(size))
1185820
public static TransposeDataCollection randomSampling(TransposeDataList clusterIdList, int sampleM) {
        TransposeDataCollection sampledIds = new TransposeDataCollection(); 
        
        Object[] selectedClusters = clusterIdList.keySet().toArray();
        PHPMethods.<Object>shuffle(selectedClusters);
        
        for(int i = 0; i<sampleM; ++i) {
            Object cluster = selectedClusters[i];
            sampledIds.put(cluster, clusterIdList.get(cluster).toFlatDataCollection());
        }
        
        
        return sampledIds;
    }
1064371
static DBIDs randomSample(DBIDs ids, int samplesize, Random rnd, DBIDs previous) {
    if(previous == null) {
      return DBIDUtil.randomSample(ids, samplesize, rnd);
    }
    ModifiableDBIDs sample = DBIDUtil.newHashSet(samplesize);
    sample.addDBIDs(previous);
    sample.addDBIDs(DBIDUtil.randomSample(ids, samplesize - previous.size(), rnd));
    // If these two were not disjoint, we can be short of the desired size!
    if(sample.size() < samplesize) {
      // Draw a large enough sample to make sure to be able to fill it now.
      // This can be less random though, because the iterator may impose an
      // order; but this is a rare code path.
      for(DBIDIter it = DBIDUtil.randomSample(ids, samplesize, rnd).iter(); sample.size() < samplesize && it.valid(); it.advance()) {
        sample.add(it);
      }
    }
    return sample;
  }
1220426
public static void sampleWithoutReplacement(int[] array, int numArgClasses, Random rand) {
    int[] temp = new int[numArgClasses];
    for (int i = 0; i < temp.length; i++) {
      temp[i] = i;
    }
    shuffle(temp, rand);
    System.arraycopy(temp, 0, array, 0, array.length);
  }