Package com.jidesoft.utils
Class MathUtils
- java.lang.Object
-
- com.jidesoft.utils.MathUtils
-
public final class MathUtils extends java.lang.Object
A collection of several util methods related to Math. We only used it in DefaultSummaryCalculator in JIDE Pivot Grid to calculate statistics but this class will be reserved as a place holder for methods related to Math.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
MathUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
max(java.util.List<java.lang.Number> numbers)
Returns the max number in the numbers list.static double
mean(java.util.List<java.lang.Number> numbers)
Returns the mean number in the numbers list.static double
min(java.util.List<java.lang.Number> numbers)
Returns the min number in the numbers list.static Range<java.lang.Double>
range(java.util.List<java.lang.Number> numbers)
Returns the range of numbers.static Range<java.lang.Integer>
rangeInteger(java.util.List<java.lang.Number> numbers)
Returns the range of numbers.static Range<java.lang.Long>
rangeLong(java.util.List<java.lang.Number> numbers)
Returns the range of numbers.static double
stddev(java.util.List<java.lang.Number> numbers, boolean biasCorrected)
Returns the standard deviation of the numbers.static double
sum(java.util.List<java.lang.Number> numbers)
Returns the sum number in the numbers list.static double
var(java.util.List<java.lang.Number> numbers, boolean biasCorrected)
Computes the variance of the available values.
-
-
-
Method Detail
-
sum
public static double sum(java.util.List<java.lang.Number> 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 double mean(java.util.List<java.lang.Number> numbers)
Returns the mean number in the numbers list.- Parameters:
numbers
- the numbers to calculate the mean.- Returns:
- the mean of the numbers.
-
min
public static double min(java.util.List<java.lang.Number> 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 double max(java.util.List<java.lang.Number> 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 double stddev(java.util.List<java.lang.Number> numbers, boolean biasCorrected)
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.- Returns:
- the standard deviation
-
var
public static double var(java.util.List<java.lang.Number> numbers, boolean biasCorrected)
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. ThebiasCorrected
property determines whether the "population" or "sample" value is returned by theevaluate
andgetResult
methods. To compute population variances, set this property tofalse
.- Parameters:
numbers
- the numbers to calculate the variance.biasCorrected
- true if variance is calculated by dividing by n - 1. False if by n.- Returns:
- the variance of the numbers.
-
range
public static Range<java.lang.Double> range(java.util.List<java.lang.Number> numbers)
Returns the range of numbers.- Parameters:
numbers
- the numbers to calculate the range.- Returns:
- the range of the numbers.
-
rangeInteger
public static Range<java.lang.Integer> rangeInteger(java.util.List<java.lang.Number> numbers)
Returns the range of numbers.- Parameters:
numbers
- the numbers to calculate the range.- Returns:
- the range of the numbers.
-
rangeLong
public static Range<java.lang.Long> rangeLong(java.util.List<java.lang.Number> numbers)
Returns the range of numbers.- Parameters:
numbers
- the numbers to calculate the range.- Returns:
- the range of the numbers.
-
-