Class BigDecimalMathUtils

java.lang.Object
com.jidesoft.utils.BigDecimalMathUtils

public final class BigDecimalMathUtils extends Object
A collection of several util methods related to BigDecimal. We only used it in BigDecimalSummaryCalculator in JIDE Pivot Grid. but this class will be reserved as a place holder for methods related to BigDecimal.
  • Field Details

  • Constructor Details

    • BigDecimalMathUtils

      protected BigDecimalMathUtils()
  • Method Details

    • sum

      public static BigDecimal sum(List<BigDecimal> numbers)
      Returns the sum number in the numbers list.
      Parameters:
      numbers - the numbers to calculate the sum.
      Returns:
      the sum of the numbers.
    • mean

      public static BigDecimal mean(List<BigDecimal> numbers, MathContext context)
      Returns the mean number in the numbers list.
      Parameters:
      numbers - the numbers to calculate the mean.
      context - the MathContext.
      Returns:
      the mean of the numbers.
    • min

      public static BigDecimal min(List<BigDecimal> numbers)
      Returns the min number in the numbers list.
      Parameters:
      numbers - the numbers to calculate the min.
      Returns:
      the min number in the numbers list.
    • max

      public static BigDecimal max(List<BigDecimal> numbers)
      Returns the max number in the numbers list.
      Parameters:
      numbers - the numbers to calculate the max.
      Returns:
      the max number in the numbers list.
    • range

      public static Range<BigDecimal> range(List<BigDecimal> numbers)
      Returns the max number in the numbers list.
      Parameters:
      numbers - the numbers to calculate the max.
      Returns:
      the max number in the numbers list.
    • stddev

      public static BigDecimal stddev(List<BigDecimal> numbers, boolean biasCorrected, MathContext context)
      Returns the standard deviation of the numbers.

      Double.NaN is returned if the numbers list is empty.

      Parameters:
      numbers - the numbers to calculate the standard deviation.
      biasCorrected - true if variance is calculated by dividing by n - 1. False if by n. stddev is a sqrt of the variance.
      context - the MathContext
      Returns:
      the standard deviation
    • var

      public static BigDecimal var(List<BigDecimal> numbers, boolean biasCorrected, MathContext context)
      Computes the variance of the available values. By default, the unbiased "sample variance" definitional formula is used: variance = sum((x_i - mean)^2) / (n - 1)

      The "population variance" ( sum((x_i - mean)^2) / n ) can also be computed using this statistic. The biasCorrected property determines whether the "population" or "sample" value is returned by the evaluate and getResult methods. To compute population variances, set this property to false.

      Parameters:
      numbers - the numbers to calculate the variance.
      biasCorrected - true if variance is calculated by dividing by n - 1. False if by n.
      context - the MathContext
      Returns:
      the variance of the numbers.
    • sqrt

      public static BigDecimal sqrt(BigDecimal number)
      Calcualtes the square root of the number.
      Parameters:
      number - the input number.
      Returns:
      the square root of the input number.
    • main

      public static void main(String[] args)