sampling based least squares