Making scaling calculation standalone function
the calculation of the scaling (so the std) as done here can be moved into a separate standalone function also with the possibility of adding weights
the calculation of the scaling (so the std) as done here can be moved into a separate standalone function also with the possibility of adding weights