The stats library contains a simple Stats
class for statistical calculations. It works on lists of Decimal
numbers so that the required precision can be obtained.
Modifier and type | Method |
---|---|
static Decimal |
mean(List<Decimal> nums) |
static Decimal |
geometricMean(List<Decimal> nums) |
static Decimal |
harmonicMean(List<Decimal> nums) |
static Decimal |
median(List<Decimal> nums) |
static Decimal |
lowerQuartile(List<Decimal> nums) |
static Decimal |
upperQuartile(List<Decimal> nums) |
static Decimal |
midhinge(List<Decimal> nums) |
static Decimal |
min(List<Decimal> nums) |
static Decimal |
max(List<Decimal> nums) |
static Decimal |
range(List<Decimal> nums) |
static Decimal |
midrange(List<Decimal> nums) |
static Decimal |
mode(List<Decimal> nums) |
static Decimal |
variance(List<Decimal> nums) |
static Decimal |
sampleVariance(List<Decimal> nums) |
static Decimal |
standardDeviation(List<Decimal> nums) |
static Decimal |
sampleStandardDeviation(List<Decimal> nums) |
static Decimal |
coefficientOfVariation(List<Decimal> nums) |
Arithmetic mean.
Geometric mean. All values need to be positive, otherwise it does not exist.
Harmonic mean. All values need to be positive, otherwise it does not exist.
Median, considered to be the middle element for odd number of elements, and an arithmetic mean of two middle elements for even number of elements. For example, the median of (1, 2, 3, 4, 5) is 3, while the median of (1, 2, 3, 4) is 2.5.
Median of those elements that are smaller than the median. For example, in list (1, 2, 3, 4, 5, 6, 7), the median is 4. (1, 2, 3) are smaller than 4, therefore the lowerQuartile
is the median of that list, which is 2.
Median of those elements that are larger than the median. For example, in list (1, 2, 3, 4, 5, 6, 7), the median is 4. (5, 6, 7) are smaller than 4, therefore the upperQuartile
is the median of that list, which is 6.
Mean of lowerQuartile
and upperQuartile
values.
Minimal value.
Maximal value.
Range of all values, which is the difference between max
and min
values.
Mean of min
and max
values.
Value that appears most often in the list. This might not be a unique value.
Variance of values.
Variance of values corrected for bias.
Standard deviation of values, calculated as a square root of variance
.
Standard deviation corrected for bias, calculated as a square root of sampleVariance
.
Calculated as standardDeviation
divided by mean
.