Here you can find the source of getMean(final BigDecimal... vals)
protected static BigDecimal getMean(final BigDecimal... vals)
//package com.java2s; //License from project: Open Source License import java.math.BigDecimal; public class Main { protected static BigDecimal getMean(final BigDecimal... vals) { int count = 0; BigDecimal sum = new BigDecimal(0); for (final BigDecimal d : vals) { if (d == null) { continue; }//from ww w. j a va 2 s . c om sum = sum.add(d); count++; } if (count == 0) { return null; } return sum.divide(new BigDecimal(count), BigDecimal.ROUND_HALF_UP); } }