compute_mean_std

Summary: Computes both the arithmetic mean and standard deviation of a given range of numbers in a single pass. This function is optimized for performance by avoiding multiple iterations over the data.

@safe
compute_mean_std
(
R
)

Parameters

numbers R

Input range containing numerical values.

Return Value

Type: auto

result: A tuple containing two values: - The computed mean (first element). - The computed standard deviation (second element).

Notes: - If the input range is empty, the function returns (0.0L, 0.0L). - Uses a numerically stable formula to compute variance and standard deviation in a single iteration. - This function is marked nothrow, @safe, and @nogc, making it suitable for use in environments requiring strict memory safety. - If numbers contains extreme values (outliers), consider using a robust mean or deviation estimator. - Standard deviation calculation follows the population formula; if the sample standard deviation is needed, modify the denominator to n - 1.