When using the math::stats function the mean value is calculated as integer instead of double. In the function the typecast to double is missing when calculating the mean value.