move weight vector and weighted sum to weights.jl