Returns the sum of seen values. If any value is a NaN or the sum is at any point a NaN then the average will be
NaN. The average returned can vary depending upon the order in which values are seen.

@return the sum of values
512260
Double getSum() {
      if (count == 0) {
         return null;
      }
      // Better error bounds to add both terms as the final sum
      double tmp = sum + sumCompensation;
      if (Double.isNaN(tmp) && Double.isInfinite(simpleSum)) {
         // If the compensated sum is spuriously NaN from
         // accumulating one or more same-signed infinite values,
         // return the correctly-signed infinity stored in simpleSum.
         return simpleSum;
      } else {
         return tmp;
      }
   }
1041690
@Override
    public double getMean() {
        if (values.length == 0) {
            return 0;
        }

        double sum = 0;
        for (long value : values) {
            sum += value;
        }
        return sum / values.length;
    }
721670
public static double sum(final Iterable<Double> values) {
    double ret = 0.0;
    for (final double d : values) {
      ret += d;
    }
    return ret;
  }
1145255
def avg(self):
        """"""
        # XXX rename this method
        if len(self.values) > 0:
            return sum(self.values) / float(len(self.values))
        else:
            return None
636945
public static <T extends Number> double getAverage(Collection<T> values, AVERAGE_TYPE type) {
		switch(type) {
			case ARITHMETIC:
				double sum = 0.0;
				for(T t: values) {
					sum += t.doubleValue();
				}
				return sum/values.size();
			default: throw new IllegalArgumentException("\""+type+"\" is not a valid verage-type!");
		}
	}
1362963
public double calculateAUC() {
        if (auc != null) {
            return auc;
        }

        if (exampleCount == 0) {
            return Double.NaN;
        }

        this.auc = getRocCurve().calculateAUC();
        return auc;
    }
1270377
public double sum() {
        double sum = 0;
        TIntDoubleIterator iter = edges.iterator();
        while (iter.hasNext()) {
            iter.advance();
            sum += iter.value();
        }
        return sum;
    }
153746
@Override
	public double getVariance() {
		if(isDeterministic()) {
			return 0.0;
		}
		if(size() == 0) {
			return Double.NaN;
		}

		double sum			= 0.0;
		double sumOfSquared = 0.0;
		double errorOfSum			= 0.0;
		double errorOfSumSquared	= 0.0;
		for(int i=0; i<realizations.length; i++) {
			double value	= realizations[i] - errorOfSum;
			double newSum	= sum + value;
			errorOfSum		= (newSum - sum) - value;
			sum				= newSum;

			double valueSquared		= realizations[i] * realizations[i] - errorOfSumSquared;
			double newSumOfSquared	= sumOfSquared + valueSquared;
			errorOfSumSquared		= (newSumOfSquared-sumOfSquared) - valueSquared;
			sumOfSquared			= newSumOfSquared;
		}
		return (sumOfSquared/realizations.length - sum/realizations.length*sum/realizations.length);
	}
256802
public static double sum (double zero, Iterable<? extends Number> values)
    {
        for (Number value : values) {
            zero += value.doubleValue();
        }
        return zero;
    }
409007
@Override
    public double average()
    {
        readLock.lock();
        try
        {
            int count = count();
            double s = 0;
            double c = 0;
            PrimitiveIterator.OfInt it = modIterator();
            while (it.hasNext())
            {
                int m = it.nextInt();
                s += sin[m];
                c += cos[m];
            };
            return toDegrees(s / count, c / count);
        }
        finally
        {
            readLock.unlock();
        }
    }
178897
public static int sum( InterleavedU8 img ) {

		if( BoofConcurrency.USE_CONCURRENT ) {
			return ImplImageStatistics_MT.sum(img);
		} else {
			return ImplImageStatistics.sum(img);
		}
	}
146183
public Double getVariance() {
		if (counter == 0) {
			return Double.NaN;
		} else {
			final double mean = computeMean();
			final double meanSquare = mean * mean;
			final double squareMean = ((double) squareTotal) / counter;
			return squareMean - meanSquare;
		}
	}
1114977
public static double sum(Array array) throws ExpressionException {
	if (array.getDimension() > 1) throw new ExpressionException("can only get sum/avg from 1 dimensional arrays");

	double rtn = 0;
	int len = array.size();
	// try {
	for (int i = 1; i <= len; i++) {
	    rtn += _toDoubleValue(array, i);
	}
	/*
	 * } catch (PageException e) { throw new
	 * ExpressionException("exception while execute array operation: "+e.getMessage()); }
	 */
	return rtn;
    }
710622
@Override
	public double getAverage(RandomVariable probabilities) {
		if(isDeterministic()) {
			return valueIfNonStochastic;
		}
		if(size() == 0) {
			return Double.NaN;
		}

		return this.cache().mult(probabilities).getRealizationsStream().sum();
	}
116729
public double sum() {
        double sum = 0;
        for (WeightedDirectedTypedEdge<T> e : inEdges.values())
            sum += e.weight();
        for (WeightedDirectedTypedEdge<T> e : outEdges.values())
            sum += e.weight();
        return sum;
    }
286523
public static function average($values)
    {
        $sum = array_sum($values);
        $count = count($values);

        // Avoid useless calculations
        if ($count == 0) {
            return 0;
        }

        return $sum / $count;
    }
130384
public static double Mean( int[] values ) {
        int     hits;
        long    total = 0;
        double  mean = 0;

        // for all values
        for ( int i = 0, n = values.length; i < n; i++ ) {
            hits = values[i];
            // accumulate mean
            mean += i * hits;
            // accumalate total
            total += hits;
        }
        return ( total == 0 ) ? 0 : mean / total;
    }