How can I simplify the following code that calculates standard deviation
If the method calculate standard desviation, it should return the value, not assign a global variable or instance variable.

Regards,