Counts sum of all the bins inside the histogram

@param histogram Histogram with N bins
@param N number of bins in the histogram.
@return Sum of all values in the histogram array.
435700
public static int count(int[] histogram, int N) {
		int counts = 0;
		for(int i=0;i<N;i++) {
			counts += histogram[i];
		}
		return counts;
	}
246587
def set_sum_w2(self, w, ix, iy=0, iz=0):
        
        if self.GetSumw2N() == 0:
            raise RuntimeError(
                "Attempting to access Sumw2 in histogram "
                "where weights were not stored")
        xl = self.nbins(axis=0, overflow=True)
        yl = self.nbins(axis=1, overflow=True)
        idx = xl * yl * iz + xl * iy + ix
        if not 0 <= idx < self.GetSumw2N():
            raise IndexError("bin index out of range")
        self.GetSumw2().SetAt(w, idx)
1019581
public void add(final DoubleHistogram fromHistogram) throws ArrayIndexOutOfBoundsException {
        int arrayLength = fromHistogram.integerValuesHistogram.countsArrayLength;
        AbstractHistogram fromIntegerHistogram = fromHistogram.integerValuesHistogram;
        for (int i = 0; i < arrayLength; i++) {
            long count = fromIntegerHistogram.getCountAtIndex(i);
            if (count > 0) {
                recordValueWithCount(
                        fromIntegerHistogram.valueFromIndex(i) *
                                fromHistogram.integerToDoubleValueConversionRatio,
                        count);
            }
        }
    }
1132989
private static void getCounts(BaseArray T, BaseArray C, int n, int k) {
        for (int i = 0; i < k; ++i) {
            C.set(i, 0);
        }
        for (int i = 0; i < n; ++i) {
            C.update(T.get(i), 1);
        }
    }
801591
public static /*@pure@*/ int sum(int[] ints) {

    int sum = 0;

    for (int i = 0; i < ints.length; i++) {
      sum += ints[i];
    }
    return sum;
  }
1159322
public static long count(int n, int m) {
		if(n == m) {
			return NumberUtil.factorial(n);
		}
		return (n > m) ? NumberUtil.factorial(n, n - m) : 0;
	}
490589
public Histogram histogram(String id, int[] data, double[] breaks, Color color) {
        if (base.dimension != 2) {
            throw new IllegalArgumentException("Histogram can be only painted in a 2D canvas.");
        }

        Histogram histogram = new Histogram(data, breaks);
        histogram.setID(id);
        histogram.setColor(color);

        double[] lowerBound = {Math.min(data) - 0.5, 0};
        double[] upperBound = {Math.max(data) + 0.5, 0};
        double[][] freq = histogram.getHistogram();
        for (int i = 0; i < freq.length; i++) {
            if (freq[i][1] > upperBound[1]) {
                upperBound[1] = freq[i][1];
            }
        }

        extendBound(lowerBound, upperBound);
        add(histogram);

        return histogram;
    }
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;
    }
1273815
@Override void add0( DRealHistogram dsh ) {
    Utils.add(_sums,dsh._sums);
    Utils.add(_ssqs,dsh._ssqs);
  }
731369
public static int countNonZero(DMatrixRMaj A){
        int total = 0;
        for (int row = 0, index=0; row < A.numRows; row++) {
            for (int col = 0; col < A.numCols; col++,index++) {
                if( A.data[index] != 0 ) {
                    total++;
                }
            }
        }
        return total;
    }
1178540
protected int computeHistogramBin( float value[] ) {
		int indexHistogram = 0;
		int binStride = 1;
		for( int bandIndex = 0; bandIndex < value.length; bandIndex++ ) {
			int bin = (int)(numBins*value[bandIndex]/maxPixelValue);

			indexHistogram += bin*binStride;
			binStride *= numBins;
		}
		return indexHistogram;
	}
266699
private static double[][] histogram(double[] data, int k, boolean prob) {
        double[][] hist = smile.math.Histogram.histogram(data, k);

        // The number of bins may be extended to cover all data.
        k = hist[0].length;
        double[][] freq = new double[k][2];
        for (int i = 0; i < k; i++) {
            freq[i][0] = (hist[0][i] + hist[1][i]) / 2.0;
            freq[i][1] = hist[2][i];
        }

        if (prob) {
            double n = data.length;
            for (int i = 0; i < k; i++) {
                freq[i][1] /= n;
            }
        }

        return freq;
    }
461494
public Histogram toHistogram(final float[] breaks)
  {
    final double[] approximateBins = new double[breaks.length - 1];

    double prev = sum(breaks[0]);
    for (int i = 1; i < breaks.length; ++i) {
      double s = sum(breaks[i]);
      approximateBins[i - 1] = (float) (s - prev);
      prev = s;
    }

    return new Histogram(breaks, approximateBins);
  }
966610
public void histogramToStructure(int histogram[] ) {
        col_idx[0] = 0;
        int index = 0;
        for (int i = 1; i <= numCols; i++) {
            col_idx[i] = index += histogram[i-1];
        }
        nz_length = index;
        growMaxLength( nz_length , false);
        if( col_idx[numCols] != nz_length )
            throw new RuntimeException("Egads");
    }
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;
    }
  }
1237713
public Histogram histogram(int[] data, double[] breaks, Color color) {
        return histogram(null, data, breaks, color);
    }
408342
private Metric collectHistogram(String dropwizardName, Histogram histogram) {
    String metricName = DropWizardUtils.generateFullMetricName(dropwizardName, "histogram");
    String metricDescription =
        DropWizardUtils.generateFullMetricDescription(dropwizardName, histogram);
    return collectSnapshotAndCount(
        metricName, metricDescription, DEFAULT_UNIT, histogram.getSnapshot(), histogram.getCount());
  }