Skip to content

Commit 4ae5d6c

Browse files
committed
comments
1 parent 97074f2 commit 4ae5d6c

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

pynumdiff/utils/utility.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ def estimate_integration_constant(x, x_hat, M=6):
139139
"""
140140
sigma = median_abs_deviation(x - x_hat, scale='normal') # M is in units of this robust scatter metric
141141
if M == float('inf') or sigma < 1e-3: # If no scatter, then no outliers, so use L2
142-
return np.mean(x - x_hat) # Solves the L2 distance minimization, argmin_{x0} ||x_hat + x0 - x||_2^
143-
elif M < 1e-3: # small M looks like L1 loss, and Huber gets too flat to work well
144-
return np.median(x - x_hat) # Solves the L1 distance minimization
142+
return np.mean(x - x_hat) # Solves the l2 distance minimization, argmin_{x0} ||x_hat + x0 - x||_2^2
143+
elif M < 1e-3: # small M looks like l1 loss, and Huber gets too flat to work well
144+
return np.median(x - x_hat) # Solves the l1 distance minimization, argmin_{x0} ||x_hat + x0 - x||_1
145145
else:
146146
return minimize(lambda x0: np.sum(huber(x - (x_hat+x0), M*sigma)), # fn to minimize in 1st argument
147147
0, method='SLSQP').x[0] # result is a vector, even if initial guess is just a scalar

0 commit comments

Comments
 (0)