A quadratic weight selection algorithm