Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Issue 3376 : stats f_oneway needs floats #3416

wants to merge 2 commits into from

5 participants

@josef-pkt josef-pkt added this to the 0.14.0 milestone

Thanks looks good to me, you could add an integer unit test.

Some possibilities:
I think using float64 is the right thing for stats. I don't know if anyone would want to use low precision with float32 for this but I would think that's unlikely.
However, for machines that can handle it correctly, we could leave higher precision than float64 unchanged. (I never checked and I think on Windows float96 doesn't do anything better than float64).
There are some tougher NIST test cases that f_oneway cannot handle in float64 without rescaling or shifting the data by the user, IIRC.

@rgommers A simple fix that should be quite innocent, I add 0.14 milestone. Reset to 0.15 if it's too late.


Coverage Status

Coverage remained the same when pulling 47016ac on ankit-maverick:issue3376 into 4b4620b on scipy:master.

@pv pv added the PR label
@rgommers rgommers self-assigned this
@rgommers rgommers modified the milestone: 0.15.0, 0.14.0

@josef-pkt we're really overdue and this isn't critical, so pushing to 0.15.0

@rgommers rgommers referenced this pull request from a commit
@rgommers rgommers Merge branch 'pr/3416' into master.
Reviewed at #3416

Pushed with some minor style changes as fb99db7. Thanks Ankit, Josef.

@rgommers rgommers closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 1 deletion.
  1. +2 −1  scipy/stats/
  2. +8 −0 scipy/stats/tests/
3  scipy/stats/
@@ -2370,7 +2370,8 @@ def f_oneway(*args):
.. [2] Heiman, G.W. Research Methods in Statistics. 2002.
- args = list(map(np.asarray, args)) # convert to an numpy array
+ # convert to an numpy array
+ args = [np.asarray(arg, dtype=float) for arg in args]
na = len(args) # ANOVA on 'na' groups, each in it's own array
alldata = np.concatenate(args)
bign = len(alldata)
8 scipy/stats/tests/
@@ -2660,6 +2660,14 @@ def test_basic(self):
# result in F being exactly 2.0.
assert_equal(F, 2.0)
+ def test_large_integer_array(self):
+ # A test of stats.f_oneway on an array of type np.uint16, with large
+ # integer values
+ a = np.array([655, 788], dtype=np.uint16)
+ b = np.array([789, 772], dtype=np.uint16)
+ F, p = stats.f_oneway(a, b)
+ assert_almost_equal(F, 0.77450216931805538)
class TestKruskal(TestCase):
Something went wrong with that request. Please try again.