Computes entropy for an array of integers.

@param counts array of counts
@return - a log2 a - b log2 b - c log2 c + (a+b+c) log2 (a+b+c)
when given array [a b c]
321894
public static /*@pure@*/ double info(int counts[]) {
    
    int total = 0;
    double x = 0;
    for (int j = 0; j < counts.length; j++) {
      x -= xlogx(counts[j]);
      total += counts[j];
    }
    return x + xlogx(total);
  }
129186
public static int[] shuffleIndices (int length, RandomGenerator randomGenerator) {
        // Initialize indices:
        final int[] indices = IntStream.range(0, length).toArray();

        // Shuffle the array:
        MathArrays.shuffle(indices, randomGenerator);

        // Done return shuffled indices:
        return indices;
    }
838260
public StatisticImpl[] getJ2EEStatistics() {
        ArrayList members = copyStatistics();
        if (members == null || members.size() == 0)
            return new StatisticImpl[0];

        StatisticImpl[] ret = new StatisticImpl[members.size()];
        for (int i = 0; i < ret.length; i++) {
            ret[i] = (StatisticImpl) members.get(i);
        }
        return ret;
    }
492699
public BigInteger getTotalCounts(){
		BigInteger result = BigInteger.ZERO;
		for (AtomicLong c: counters.getMap().values()){
			result = result.add(BigInteger.valueOf(c.get()));
		}
		return result;
	}
198313
def entropy_calc(item, POP):
    
    try:
        result = 0
        for i in item.keys():
            likelihood = item[i] / POP[i]
            if likelihood != 0:
                result += likelihood * math.log(likelihood, 2)
        return -result
    except Exception:
        return "None"
1100843
private static int sum(final int[] sizes) {
        int sum = 0;
        for (int i = sizes.length - 1; i >= 0; i--) {
            sum += sizes[i];
        }
        return sum;
    }
367357
public static IntMoments of(final IntMomentStatistics statistics) {
		return new IntMoments(
			statistics.getCount(),
			statistics.getMin(),
			statistics.getMax(),
			statistics.getSum(),
			statistics.getMean(),
			statistics.getVariance(),
			statistics.getSkewness(),
			statistics.getKurtosis()
		);
	}
1352832
public int count(T x, T y) {
        long index = getIndex(x, y);
        int count = counts.get(index);
        count++;
        counts.put(index, count);
        sum++;
        return count;
    }
977561
def entropy_bits(
        lst: Union[
            List[Union[int, str, float, complex]],
            Tuple[Union[int, str, float, complex]]
        ]
) -> float:
    """"""
    # Based on https://stackoverflow.com/a/45091961
    if not isinstance(lst, (list, tuple)):
        raise TypeError('lst must be a list or a tuple')

    for num in lst:
        if not isinstance(num, (int, str, float, complex)):
            raise TypeError('lst can only be comprised of int, str, float, '
                            'complex')

    n_lst = len(lst)

    if n_lst <= 1:
        return 0.0

    # Some NumPy replacements
    counts = [lst.count(x) for x in lst]
    probs = [c / n_lst for c in counts]

    # Compute entropy
    entropy = 0.0
    for prob in probs:
        entropy -= prob * log2(prob)

    return entropy
375491
public int count(T x, T y, int count) {
        if (count < 1)
            throw new IllegalArgumentException("Count must be positive: " + count);
        long index = getIndex(x, y);
        int oldCount = counts.get(index);
        int newCount = count + oldCount;
        counts.put(index, newCount);
        sum += count;
        return newCount;
    }
197917
public static int count(final Iterable<Range<Long>> ranges) {
        int count = 0;
        for (Range<Long> range : ranges) {
            checkClosedOpen(range);
            count++;
        }
        return count;
    }
435700
public static int count(int[] histogram, int N) {
		int counts = 0;
		for(int i=0;i<N;i++) {
			counts += histogram[i];
		}
		return counts;
	}
257461
def entropy(string):
    """"""
    p, lns = Counter(string), float(len(string))
    return -sum(count/lns * math.log(count/lns, 2) for count in p.values())
425810
def entropy(data):
    

    if len(data) == 0:
        return None

    n = sum(data)

    _op = lambda f: f * math.log(f)
    return - sum(_op(float(i) / n) for i in data)
36189
function count(arr) {
                var c = 0;
                for (var i = 0; i < arr.length; i++) {
                    c += creator[arr[i] & 0xff] + creator[(arr[i] >> 8) & 0xff] + creator[(arr[i] >> 16) & 0xff] + creator[(arr[i] >> 24) & 0xff];
                }
                return c;
            }
308328
def compute_stats2(arrayNR, stats, weights):
    
    newshape = list(arrayNR.shape)
    if newshape[1] != len(weights):
        raise ValueError('Got %d weights but %d values!' %
                         (len(weights), newshape[1]))
    newshape[1] = len(stats)  # number of statistical outputs
    newarray = numpy.zeros(newshape, arrayNR.dtype)
    data = [arrayNR[:, i] for i in range(len(weights))]
    for i, func in enumerate(stats):
        newarray[:, i] = apply_stat(func, data, weights)
    return newarray
1334049
public static Statistics statisticsOf(List<Statistics> data) {
        if (data.isEmpty())
            return null;
        
        Iterator<Statistics> iterator = data.iterator();
        if (!iterator.hasNext()) {
            return null;
        }
        Statistics first = null;
        while (first == null && iterator.hasNext()) {
            first = iterator.next();
        }
        if (first == null)
            return null;
        
        int count = first.getCount();
        double min = first.getMinimum().doubleValue();
        double max = first.getMaximum().doubleValue();
        double total = first.getAverage() * first.getCount();
        double totalSquare = (first.getStdDev() * first.getStdDev() + first.getAverage() * first.getAverage()) * first.getCount();
        
        while (iterator.hasNext()) {
            Statistics stats = iterator.next();
            if (stats.getMaximum().doubleValue() > max)
                max = stats.getMaximum().doubleValue();
            if (stats.getMinimum().doubleValue() < min)
                min = stats.getMinimum().doubleValue();
            total += stats.getAverage() * stats.getCount();
            totalSquare += ( stats.getStdDev() * stats.getStdDev() + stats.getAverage() * stats.getAverage() ) * stats.getCount();
            count += stats.getCount();
        }
        
        double average = total/count;
        double stdDev = Math.sqrt(totalSquare / count - average * average);
        
        return new StatisticsImpl(count, min, max, average, stdDev);
    }