zScore - multiple declarations

Function zScore

Returns a range with whatever properties T has (forward range, random access range, bidirectional range, hasLength, etc.), of the z-scores of the underlying range. A z-score of an element in a range is defined as (element - mean(range)) / stdev(range).

ZScore!T zScore(T) (
  T range
)
if (isForwardRange!T && doubleInput!T);

Notes

If the data contained in the range is a sample of a larger population, rather than an entire population, then technically, the results output from the ZScore range are T statistics, not Z statistics. This is because the sample mean and standard deviation are only estimates of the population parameters. This does not affect the mechanics of using this range, but it does affect the interpretation of its output.

Accessing elements of this range is fairly expensive, as a floating point multiply is involved. Also, constructing this range is costly, as the entire input range has to be iterated over to find the mean and standard deviation.

Function zScore

Allows the construction of a ZScore range with precomputed mean and stdev.

ZScore!T zScore(T) (
  T range,
  double mean,
  double sd
)
if (isForwardRange!T && doubleInput!T);