You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
jackknife_stats silently gives wrong results for a MaskedArray: masked values leak into the resamples #20579
If jackknife_stats gets a numpy.ma.MaskedArray, for example a light curve with flagged bad points, it returns no error and no warning, but the estimate, bias and standard error are wrong. The full-sample statistic honours the mask. The leave-one-out resamples do not, because the masked values are copied into them as ordinary data. The result therefore depends on the value hidden under the mask.
Expected behavior
The result should match the one for the unmasked values, estimate = 2.5, bias = 0, se = 0.6455. Alternatively, jackknife_stats could raise an error saying that masked input is not supported.
How to Reproduce
importnumpyasnpfromastropy.statsimportjackknife_stats# 5 flux measurements; the last one is flagged bad and maskeddata=np.ma.array([1.0, 2.0, 3.0, 4.0, 1000.0], mask=[0, 0, 0, 0, 1])
est, bias, se, ci=jackknife_stats(data, np.mean)
print("masked input :", est, bias, se)
est, bias, se, ci=jackknife_stats(data.compressed(), np.mean)
print("compressed :", est, bias, se)
Activity
rajpreetcodes commentedon Oct 11, 2026
I investigated this root cause and opened PR #20582 with the fix and regression test suite.