Constructs a histogram with the "MaxDiff(V, F)" buckets for all fields.

@param numBkts
the number of buckets to construct for each field
@param numPcts
the number of value percentiles in each bucket
@return a "MaxDiff(V, F)" histogram
552720
public Histogram newMaxDiffFreqHistogram(int numBkts, int numPcts) {
		Map<String, BucketBuilder> initBbs = new HashMap<String, BucketBuilder>();
		// initialize the first bucket builder for every field
		for (String fld : schema.fields())
			initBbs.put(fld, new MaxDiffFreqBucketBuilder(frequencies(fld),
					numPcts));
		return newMaxDiffHistogram(numBkts, initBbs);
	}
210928
@Override
  protected void linearScanBatchKNN(List<O> objs, List<KNNHeap> heaps) {
    final SquaredEuclideanDistanceFunction squared = SquaredEuclideanDistanceFunction.STATIC;
    final Relation<? extends O> relation = getRelation();
    final int size = objs.size();
    // Linear scan style KNN.
    for(DBIDIter iter = relation.getDBIDs().iter(); iter.valid(); iter.advance()) {
      O candidate = relation.get(iter);
      for(int index = 0; index < size; index++) {
        final KNNHeap heap = heaps.get(index);
        final double dist = squared.distance(objs.get(index), candidate);
        if(dist <= heap.getKNNDistance()) {
          heap.insert(dist, iter);
        }
      }
    }
  }
1123719
@Pure
	public static MathFunctionRange[] createDiscreteSet(double... values) {
		final MathFunctionRange[] bounds = new MathFunctionRange[values.length];
		for (int i = 0; i < values.length; ++i) {
			bounds[i] = new MathFunctionRange(values[i]);
		}
		return bounds;
	}
647487
public static int max(IntTuple t)
    {
        return IntTupleFunctions.reduce(
            t, Integer.MIN_VALUE, Math::max);
    }
739938
private static function randFloat($min, $max, $decimals = 0.01)
    {
        $decimals = 1 / $decimals;

        return mt_rand($min * $decimals, $max * $decimals) / $decimals;
    }
233461
def knuth(data):
        
        import scipy.optimize as optimize

        def f(data):
            from scipy.special import gammaln

            m, M = np.min(data), np.max(data)
            n = len(data)

            def fff(x):
                k = x[0]  # number of bins
                if k <= 0:
                    return float("+inf")
                binning = np.linspace(m, M, k + 1)
                histo, bincenters = np.histogram(data, binning)

                return -(n * np.log(k) + gammaln(k / 2.) - gammaln(n + k / 2.) +
                         k * gammaln(1. / 2.) + np.sum(gammaln(histo + 0.5)))
            return fff

        k0 = np.sqrt(len(data))
        return optimize.fmin(f(data), np.array([k0]), disp=False)[0]
811594
def percentile(values, k):
    
    if not values:
        return None
    values.sort()
    index = (len(values) * (float(k) / 100)) - 1
    return values[int(math.ceil(index))]
1139420
public static /*@pure@*/ int maxIndex(int[] ints) {

    int maximum = 0;
    int maxIndex = 0;

    for (int i = 0; i < ints.length; i++) {
      if ((i == 0) || (ints[i] > maximum)) {
	maxIndex = i;
	maximum = ints[i];
      }
    }

    return maxIndex;
  }
1292069
private int computeTargetPartitionSize(Histogram histogram, int minTargetPartitionSize, int maxPartitions) {
     return Math.max(minTargetPartitionSize,
        DoubleMath.roundToInt((double) histogram.totalRecordCount / maxPartitions, RoundingMode.CEILING));
  }
591956
def max_diff(dset1,dset2):
    ''''''
    for dset in [dset1,dset2]:
        if not os.path.exists(dset):
            nl.notify('Error: Could not find file: %s' % dset,level=nl.level.error)
            return float('inf')
    try:
        dset1_d = nib.load(dset1)
        dset2_d = nib.load(dset2)
        dset1_data = dset1_d.get_data()
        dset2_data = dset2_d.get_data()
    except IOError:
        nl.notify('Error: Could not read files %s and %s' % (dset1,dset2),level=nl.level.error)
        return float('inf')
    try:
        old_err = np.seterr(divide='ignore',invalid='ignore')
        max_val = 100*np.max(np.ma.masked_invalid(np.double(dset1_data - dset2_data) / ((dset1_data+dset2_data)/2)))
        np.seterr(**old_err)
        return max_val
    except ValueError:
        return float('inf')
1338564
public static DMatrixSparseCSC diag(double... values ) {
        int N = values.length;
        return diag(new DMatrixSparseCSC(N,N,N),values,0,N);
    }
216344
protected <T> List<List<T>> trivialPartition(List<T> objects, int minEntries, int maxEntries) {
    // build partitions
    final int size = objects.size();
    final int numberPartitions = (int) Math.ceil(((double) size) / maxEntries);
    List<List<T>> partitions = new ArrayList<>(numberPartitions);
    int start = 0;
    for(int pnum = 0; pnum < numberPartitions; pnum++) {
      int end = (int) ((pnum + 1.) * size / numberPartitions);
      if(pnum == numberPartitions - 1) {
        end = size;
      }
      assert ((end - start) >= minEntries && (end - start) <= maxEntries);
      partitions.add(objects.subList(start, end));
      start = end;
    }
    return partitions;
  }
370120
def _get_delta(self, stds, dists):
        
        delta = np.maximum((0.1-0.001*dists.repi), np.zeros_like(dists.repi))
        return delta
925544
private double max(ArrayList<DistanceSet> v) {
        double max = 0.0;
        for (DistanceSet n : v) {
            if (max < n.dist.get(n.dist.size() - 1)) {
                max = n.dist.get(n.dist.size() - 1);
            }
        }
        return max;
    }
267020
public static long maximum(long... values)
    {
        int len = values.length;
        long current = values[0];

        for (int i=1; i < len; i++)
        {
            current = Math.max(values[i], current);
        }

        return current;
    }
527879
def histogram(a, bins):
    
    if any(map(lambda x: x < 0, diff(bins))):
        raise ValueError(
            'bins must increase monotonically.')

    try:
        sa = sorted(a)
    except TypeError:
        # Perhaps just a single value? Treat as a list and carry on
        sa = sorted([a])

    # import numpy as np
    # nl = np.searchsorted(sa, bins[:-1], 'left')
    # nr = np.searchsorted(sa, bins[-1], 'right')
    # nn = np.r_[nl, nr]
    #
    # # cl = list(accumulate(Counter(map(lambda x: bisect_left(bins[:-1], x), sa)))
    # # print("cl")
    # # print([cl[i] for i in range(len(bins))])
    # print("nl")
    # print(list(nl))
    # # print(Counter(map(lambda x: bisect_right([bins[-1]], x), sa)))
    # print("nr")
    # print([nr])
    # print("nn")
    # print(list(nn))
    # print("hist")
    # print(list(np.diff(nn)))
    # print(list(np.histogram(a, bins)[0]))

    nl = list(accumulate([Counter(map(lambda x: bisect_left(bins[:-1], x), sa))[i] for i in range(len(bins) - 1)]))
    # print("nl")
    # print(nl)
    nr = Counter(map(lambda x: bisect_right([bins[1]], x), sa))[1]
    # print(nl)
    # print(nr)
    n = list(nl) + [nr]

    return diff(n), bins
1346307
public float max(float... values) {
        float max = Float.MIN_VALUE;
        for (int i = 0; i < values.length; i++) {
            if (i == 0 || values[i] > max) {
                max = values[i];
            }
        }
        
        return max;
    }