@@ -611,11 +611,12 @@ def _clock_sync(
611611 if range_i [0 ] != range_i [1 ]:
612612 start , stop = range_i [0 ], range_i [1 ] + 1
613613 e = np .ones ((stop - start ,))
614- X = np .column_stack ([e , clock_times [start :stop ]])
615- X /= winsor_threshold
616- y = clock_values [start :stop ] / winsor_threshold
614+ X = np .column_stack ([e , np .array (clock_times [start :stop ]) / winsor_threshold ])
615+ y = np .array (clock_values [start :stop ]) / winsor_threshold
617616 # noinspection PyTypeChecker
618- coef .append (_robust_fit (X , y ))
617+ _coefs = _robust_fit (X , y )
618+ _coefs [0 ] *= winsor_threshold
619+ coef .append (_coefs )
619620 else :
620621 coef .append ((clock_values [range_i [0 ]], 0 ))
621622
@@ -702,6 +703,9 @@ def _robust_fit(A, y, rho=1, iters=1000):
702703 http://www.stanford.edu/~boyd/papers/distr_opt_stat_learning_admm.html
703704
704705 """
706+ A = np .copy (A ) # Don't mutate input.
707+ offset = np .min (A [:, 1 ])
708+ A [:, 1 ] -= offset
705709 Aty = np .dot (A .T , y )
706710 L = np .linalg .cholesky (np .dot (A .T , A ))
707711 U = L .T
@@ -715,6 +719,7 @@ def _robust_fit(A, y, rho=1, iters=1000):
715719 tmp = np .maximum (0 , (1 - (1 + 1 / rho ) * np .abs (d_inv )))
716720 z = rho / (1 + rho ) * d + 1 / (1 + rho ) * tmp * d
717721 u = d - z
722+ x [0 ] -= x [1 ] * offset
718723 return x
719724
720725
0 commit comments