calc_total_sd function

Calculate total sd