Skip to content

Fix Student's T kernel formula sign error in tdist() - #593

Merged
bhaller merged 2 commits into
MesserLab:masterfrom
andrewkern:patch_tdist
Dec 17, 2025
Merged

Fix Student's T kernel formula sign error in tdist()#593
bhaller merged 2 commits into
MesserLab:masterfrom
andrewkern:patch_tdist

Conversation

@andrewkern

Copy link
Copy Markdown
Collaborator

Fixes double-negative in exponent causing strength to increase with distance:

  // Before (wrong): dividing by negative exponent = multiplying by positive
  return max / pow(base, -(nu + 1.0) / 2.0);

  // After (correct)
  return max * pow(base, -(nu + 1.0) / 2.0);

Closes #591

Also should resolve CI test failures in #592

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.
@petrelharp

Copy link
Copy Markdown
Collaborator

Ack! Good catch. Inded:
Screenshot From 2025-12-17 09-43-22

@bhaller

bhaller commented Dec 17, 2025

Copy link
Copy Markdown
Contributor

This will also make it significantly faster, since multiplication is much faster than division. Maybe this is why you saw such a large speedup for Student's T in your benchmarking, @andrewkern! Your SIMD code was doing multiplication but the original code was (incorrectly) doing division? :-O

@bhaller
bhaller merged commit 78aabea into MesserLab:master Dec 17, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Student's T spatial kernel strength increases with distance instead of decreasing

3 participants