Repository navigation
Conversation
Evaluate the normal tail with erfc to avoid cancellation for strongly ordered samples.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3675 +/- ##
=======================================
- Coverage 37% 35% -1%
=======================================
Files 349 357 +8
Lines 19901 20284 +383
=======================================
- Hits 7264 7189 -75
- Misses 12637 13095 +458 🚀 New features to boost your workflow:
|
atishay-kasliwal
left a comment
There was a problem hiding this comment.
Compared kendall_rank_corrcoef(..., t_test=True) p-values with scipy.stats.kendalltau(method='asymptotic') on float64 inputs. Here they match scipy down to 1e-26 (n=40: 1.83e-09, n=60: 5.88e-15, n=100: 5.16e-26); master returned 0.0 for all three.
| t_value = t_value.nan_to_num() | ||
| p_value = normal_dist.cdf(t_value) | ||
| return p_value.where(~is_nan, torch.tensor(float("nan"), dtype=p_value.dtype, device=p_value.device)) | ||
| return 0.5 * torch.erfc(-t_value / math.sqrt(2.0)) |
There was a problem hiding this comment.
The returned p-value is float32 even when preds/target are float64, so anything below the float32 range still comes out as 0.0. Example: n=200 with tau 0.79 gives 0.0 here, while scipy gives 1.1e-61. Computing t_value in the input dtype would keep those. Fine as a follow-up if float32 is intended.
Compute the t statistic in the promoted input dtype so float64 inputs keep tail probabilities below the float32 range.
|
Changed in 1859439: the t statistic is now computed in the promoted input dtype, so float64 inputs return a float64 p-value, while float32 and lower still return float32. The new test checks an n=200, tau 0.79 float64 case against scipy (p around 1e-62) and the float32 dtype. |
What does this PR do?
The asymptotic Kendall test returns a zero p-value for 30 strictly ordered float32 observations. The normal CDF rounds away the lower tail. Evaluate that tail with the complementary error function so the two-sided result is approximately 8.4363e-15, consistent with SciPy.
The regression covers increasing and decreasing inputs and all three alternatives. It uses a relative tolerance with zero absolute tolerance so a result of zero fails.
Before submitting