Skip to content

Commit b9e8092

Browse files
committed
Fix Student's T kernel formula sign error in tdist()
The tdist() function had a double-negative that caused strength to increase with distance instead of decrease: return max / pow(base, -(nu + 1.0) / 2.0); // wrong: dividing by negative exp Fixed to: return max * pow(base, -(nu + 1.0) / 2.0); // correct: multiply by negative exp This bug caused the Student's T spatial kernel to produce physically nonsensical results where interaction strength exceeded fmax at non-zero distances.
1 parent c5e3701 commit b9e8092

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

core/spatial_kernel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class SpatialKernel
7474
// we don't use the GSL for this, because it does two gamma-function calculations that we don't need (they normalize away)
7575
static inline double tdist(double x, double max, double nu, double tau) {
7676
double x_over_tau = x / tau;
77-
return max / pow(1.0 + x_over_tau * x_over_tau / nu, -(nu + 1.0) / 2.0);
77+
return max * pow(1.0 + x_over_tau * x_over_tau / nu, -(nu + 1.0) / 2.0);
7878
};
7979

8080
public:

0 commit comments

Comments
 (0)