Skip to content

Commit 97074f2

Browse files
committed
last touch ups
1 parent d039ab8 commit 97074f2

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

pynumdiff/optimize/_optimize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
'lmbd': (1e-3, 0.5)}),
6767
tvrdiff: ({'gamma': [1e-2, 1e-1, 1, 10, 100, 1000],
6868
'order': {1, 2, 3}, # warning: order 1 hacks the loss function when tvgamma is used, tends to win but is usually suboptimal choice in terms of true RMSE
69-
'huberM': [0., 1, 2, 3, 6]},
69+
'huberM': [0., 1, 2, 6]}, # comb lower values more finely, because the scale of sigma is mad(x), bigger than mad(y-x) residuals
7070
{'gamma': (1e-4, 1e7),
7171
'huberM': (0, 6)}),
7272
velocity: ({'gamma': [1e-2, 1e-1, 1, 10, 100, 1000]}, # Deprecated method

pynumdiff/total_variation_regularization/_total_variation_regularization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def tvrdiff(x, dt, order, gamma, huberM=float('inf'), solver=None):
8989
y = cvxpy.cumsum(y) + integration_constants[i]
9090

9191
# Compare the recursively integrated position to the noisy position. \ell_2 doesn't get scaled by 1/2 here,
92-
# so cvxpy Huber is already the right scale, and \ell_1 should be scaled by 2\sqrt{2} to match.
92+
# so cvxpy's doubled Huber is already the right scale, and \ell_1 should be scaled by 2\sqrt{2} to match.
9393
fidelity_cost = cvxpy.sum_squares(y - x) if huberM == float('inf') \
9494
else np.sqrt(8)*cvxpy.norm(y - x, 1) if huberM == 0 \
9595
else utility.huber_const(huberM)*cvxpy.sum(cvxpy.huber(y - x, huberM*sigma))

pynumdiff/utils/utility.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ def estimate_integration_constant(x, x_hat, M=6):
138138
:return: **integration constant** (float) -- initial condition that best aligns x_hat with x
139139
"""
140140
sigma = median_abs_deviation(x - x_hat, scale='normal') # M is in units of this robust scatter metric
141-
if M == float('inf') or sigma < 1e-6: # If no scatter, then no outliers, so use L2
141+
if M == float('inf') or sigma < 1e-3: # If no scatter, then no outliers, so use L2
142142
return np.mean(x - x_hat) # Solves the L2 distance minimization, argmin_{x0} ||x_hat + x0 - x||_2^
143-
elif M < 1e-2: # small M looks like L1 loss, and Huber gets too flat to work well
143+
elif M < 1e-3: # small M looks like L1 loss, and Huber gets too flat to work well
144144
return np.median(x - x_hat) # Solves the L1 distance minimization
145145
else:
146146
return minimize(lambda x0: np.sum(huber(x - (x_hat+x0), M*sigma)), # fn to minimize in 1st argument

0 commit comments

Comments
 (0)