compute weights