zScore
Computes the z-score (standard score) of each element.
The z-score expresses how many standard deviations an element is from the mean. Each value is transformed by subtracting the sample mean and dividing by the sample standard deviation. The resulting array has a mean of approximately 0 and a standard deviation of approximately 1.
Example:
doubleArrayOf(1.0, 2.0, 3.0, 4.0, 5.0).zScore()
// [-1.2649, -0.6325, 0.0, 0.6325, 1.2649] (approximately)Return
an array of z-scores in the same order as the input.
Throws
if the array has fewer than 2 elements.
if the array contains NaN or Infinity.
if the standard deviation is zero (all values are identical).
Computes the z-score (standard score) of each element in this iterable.
This is a convenience overload that accepts any Iterable. The collection is materialized to a DoubleArray internally.
Example:
listOf(1.0, 2.0, 3.0, 4.0, 5.0).zScore()
// [-1.2649, -0.6325, 0.0, 0.6325, 1.2649] (approximately)Return
a list of z-scores in the same order as the input.
See also
Throws
if the collection has fewer than 2 elements.
if the collection contains NaN or Infinity.
if the standard deviation is zero (all values are identical).