fixed bug: weight_sum calculated wrong if one weight is 0
calculating weights based on categories, not direcctly on indices :(
fixed bug in calculate_osc (NaNs in calc mean)