Randomly sample a number of sequences from the data
@param count    Number of sequences to sample
@param data     Data to sample from
@return         Sequence samples
502729
public static List<List<List<Writable>>> sampleSequence(int count, JavaRDD<List<List<Writable>>> data) {
        return data.takeSample(false, count);
    }
764236
public byte[] getBytes(int rowId, int count) {
    byte[] res = new byte[count];
    for (int i = 0; i < count; i++) {
      res[i] = getByte(rowId + i);
    }
    return res;
  }
1109299
public static int count(final Object array) {

    if (isArray(array)) {
      return Array.getLength(array);
    } else if (array != null) {
      throw new IllegalArgumentException("Given data is not an array.");
    } else {
      return 0;
    }
  }
115403
public <T> List<T> randomElements(List<T> elements, int count) {
		if (elements.size() >= count) {
			return extractRandomList(elements, count);
		} else {
			List<T> randomElements = new ArrayList<T>();
			randomElements.addAll(extractRandomList(elements, count % elements.size()));
			do {
				randomElements.addAll(extractRandomList(elements, elements.size()));
			} while (randomElements.size() < count);
			return randomElements;
		}
	}
831730
@Override
	public Iterator<T> sample(Iterator<T> input) {
		return sampleInCoordinator(sampleInPartition(input));
	}
1108263
public static DoubleStream buildRandomNumberStream(int count) {
        return IntStream.range(0, count).mapToDouble(i -> Math.random());
    }
1088884
public final double sampleCount()
  {
    synchronized (_lock) {
      long count = _count.get();
      long lastCount = _lastCount;
      _lastCount = count;

      return count - lastCount;
    }
  }
234925
protected int countCorrectPairs(MatchData data) 
	{
		// count the number of times each id appears in each source */
		Map counter = new HashMap();
		for (int i=0; i<data.numSources(); i++) {
			String src = data.getSource(i);
			for (int j=0; j<data.numInstances(src); j++){
				String id = data.getInstance(src, j).getId(); 
				if (id!=null) {
					IdKey key = new IdKey(id,src); 
					Integer c = (Integer)counter.get(key);
					counter.put( key, (c==null ? new Integer(1) : new Integer(c.intValue()+1)) );
				}
			}
		}

		/*
		// show the counter
		for (Iterator i=counter.keySet().iterator(); i.hasNext(); ) {
			IdKey key = (IdKey) i.next();
			System.out.println( key.src+"#"+key.id+" = "+counter.get(key) );
		}
		*/

		// count the number of correct pairs
		int numCorrectPairs = 0;
		Set idsInSrc1 = new HashSet();
		for (int i=0; i<data.numSources(); i++) {
			String src1 = data.getSource(i);
			idsInSrc1.clear();
			for (int j=0; j<data.numInstances(src1);j++) {
				String id = data.getInstance(src1, j).getId(); 
				idsInSrc1.add(id);
				for (int k=i+1; k<data.numSources(); k++) {
					String src2 = data.getSource(k);
					Integer cInteger = (Integer) counter.get( new IdKey(id,src2) );
					if (cInteger!=null) {
						numCorrectPairs += cInteger.intValue();
					}
					//System.out.println( "src1:"+src1+" id:"+id+" src2:"+src2+" c:"+cInteger); 
				}
			}
			if (clusterMode) {
				// count how often something in src1 can be matched correctly with something
				// else in src1
				for (Iterator j=idsInSrc1.iterator(); j.hasNext(); ) {
					String id = (String)j.next();
					Integer cInteger = (Integer) counter.get( new IdKey(id,src1) );
					int c = cInteger.intValue();
					numCorrectPairs += c*(c-1)/2;
				}
			}
		}
		return numCorrectPairs;
	}
697493
function createRandomData(count) {
  function rnd() {
    return Math.round(Math.random() * 1000) / 10;
  }
  var result = [];
  for (var i = 0; i < count; i++) {
    result.push({price:rnd(), weight:rnd(), taste:rnd()});
  }
  return result;
}
816723
public function emptyTo(& $colorData, $count) 
    {
        for ($i = 0; $i < $count; $i++) {
            $sampleCount = $this->samples[$i * 5 + self::IDX_COUNT];
            $a = $this->samples[$i * 5 + self::IDX_A];
            $color = $sampleCount == 0 || $a == 0 ? 0 :
                ColorUtils::from(
                    (int)($a / $sampleCount),
                    (int)($this->samples[$i * 5 + self::IDX_R] / $a),
                    (int)($this->samples[$i * 5 + self::IDX_G] / $a),
                    (int)($this->samples[$i * 5 + self::IDX_B] / $a)
                );
            
            $colorData[] = 1;
            $colorData[] = $color;
        }
        
        $this->pixelOffset = 0;
        $this->subPixelOffset = 0;
        $this->used = -1;
    }
193411
@SuppressWarnings("unchecked")
	public List seqLabeling(String data){
		List<Sentence> obsvSeqs = dataReader.readString(data);
		return labeling(obsvSeqs);
	}
743085
public static Distribution guessNumberOfBins(DataSet data)
    {
        if(data.size() < 20)
            return new UniformDiscrete(2, data.size()-1);
        else if(data.size() >= 1000000)
            return new LogUniform(50, 1000);
        int sqrt = (int) Math.sqrt(data.size());
        return new UniformDiscrete(Math.max(sqrt/3, 2), Math.min(sqrt*3, data.size()-1));
    }
659644
@Override
  public final void sample()
  {
    long totalCount = _totalCount.get();
    long lastTotal = _lastTotal;
    _lastTotal = totalCount;

    _value = totalCount - lastTotal;
  }
773291
public static String formatBytes(byte[] data, int start, int count) {
    if(isTracing())
      return SibTr.formatBytes(data, start, count);
    else
      return "";
  }
526862
public int writeSamples(short[] data, int numSamples)
	{
		int numBytes = numSamples<<1;
		byte[] theData = new byte[numBytes];
		for (int y = 0, yc=0; y<numBytes; y+=2)
		{
			theData[y] = (byte) (data[yc] & 0x00FF);
			theData[y + 1] = (byte) ((data[yc++] >>> 8) & 0x00FF);
		}
		return write(theData, numBytes);
	}
177621
public static String random(int count, RandomType randomType) {
		if (count == 0) return "";
		if (count < 0) {
			throw new IllegalArgumentException("Requested random string length " + count + " is less than 0.");
		}
		char[] buffer = new char[count];
		for (int i = 0; i < count; i++) {
			if (randomType.equals(RandomType.INT)) {
				buffer[i] = _INT.charAt(RANDOM.nextInt(_INT.length()));
			} else if (randomType.equals(RandomType.STRING)) {
				buffer[i] = _STR.charAt(RANDOM.nextInt(_STR.length()));
			}else {
				buffer[i] = _ALL.charAt(RANDOM.nextInt(_ALL.length()));
			}
		}
		return new String(buffer);
	}
1052532
public static byte[] intToNetworkByteOrder(int num, int count) {
        byte[] buf = new byte[count];
        intToNetworkByteOrder(num, buf, 0, count);
        
        return buf;
    }