StatisticalUtils - MeAlam1/BlueLib GitHub Wiki
StatisticalUtils
Overview
The StatisticalUtils
class provides methods for performing various statistical calculations on arrays of double values. This utility class enables the calculation of key statistical metrics, including mean, median, mode, standard deviation, variance, range, and the coefficient of variation.
Key Methods
-
calculateMean(double[])
Computes the mean (average) of an array of values.double mean = StatisticalUtils.calculateMean(new double[]{1.0, 2.0, 3.0, 4.0});
-
calculateMedian(double[])
Finds the median of an array of values.double median = StatisticalUtils.calculateMedian(new double[]{1.0, 2.0, 3.0});
-
calculateMode(double[])
Determines the mode (most frequent value) in an array of values.double mode = StatisticalUtils.calculateMode(new double[]{1.0, 2.0, 2.0, 3.0});
-
calculateStandardDeviation(double[])
Calculates the standard deviation of an array of values.double stdDev = StatisticalUtils.calculateStandardDeviation(new double[]{1.0, 2.0, 3.0, 4.0});
-
calculateVariance(double[])
Computes the variance of an array of values.double variance = StatisticalUtils.calculateVariance(new double[]{1.0, 2.0, 3.0, 4.0});
-
calculateRange(double[])
Determines the range (difference between the maximum and minimum) of an array of values.double range = StatisticalUtils.calculateRange(new double[]{1.0, 3.0, 7.0, 2.0});
-
calculateCoefficientOfVariation(double[])
Calculates the coefficient of variation (CV) of an array of values.double cv = StatisticalUtils.calculateCoefficientOfVariation(new double[]{10.0, 12.0, 15.0});
Usage Notes
- Error Handling: If an input is invalid (e.g. empty array), the method throws an appropriate exception and logs an error message.
- Utility Design: This class cannot be instantiated, as it includes a private constructor and only static methods.