documentaion for  weighted least square fitting