Skip to content

tslearn/soft-dtw-negative-gamma

Pack Severity Fix Versions
tslearn error none, edit by hand All versions

tslearn.metrics.soft_dtw_fast._njit_softmin3 divides by -gamma and uses DBL_MAX sentinel boundaries. With a negative gamma, -gamma > 0 overflows exp(DBL_MAX / (-gamma)) and silently returns nan from soft_dtw, soft_dtw_normalized, soft_dtw_alignment, cdist_soft_dtw, and cdist_soft_dtw_normalized.

score = soft_dtw_normalized(s1, s2, gamma=-1.0)
score = soft_dtw_normalized(s1, s2, gamma=1.0)

Calls to tslearn Soft-DTW distance, alignment, loss, or barycenter APIs passing a negative gamma literal.

Pass a strictly positive gamma (or gamma=0.0 for the squared hard-DTW limit), and prefer soft_dtw_normalized / cdist_soft_dtw_normalized when you need a non-negative divergence with zero self-distance.

Negative gamma in Soft-DTW flips the sign inside softmin and produces NaN distances in tslearn. Pass a non-negative smoothing parameter (gamma > 0, or gamma=0 for hard DTW squared).

See all rules in the tslearn pack.