Skip to content

scipy.stats.wilcoxon does not return z-statistic but T-value (Trac #1413) #1938

scipy-gitbot opened this Issue Apr 25, 2013 · 10 comments

1 participant


Original ticket on 2011-03-23 by trac user sickbock, assigned to unknown.

The documentation of scipy.stats.wilcoxon states that the tuple (z, p) is returned, where z is the z-statistic. This value is calculated in [1], but the T statistic is returned in the code:

I think that either
1) the docstring should be updated to reflect that the T-value is returned or
2) the z-statistic should be returned instead.


Milestone changed to Unscheduled by @rgommers on 2011-03-27


@josef-pkt wrote on 2011-03-27

I would consider it for now as a documentation issue, that is 1) update docstring.

The T value is more useful than the z-statistic, which can also be recovered from the p-value. Also, this doesn't break backwards compatibility

As a stats review it would be interesting to compare the different statistical tests for inconsistencies, and if necessary or useful, change several of them at once to make it consistent.
(I haven't looked what the pattern is, but I guess it's inconsistent.)


trac user sickbock wrote on 2011-03-28

Can I contribute to the stats module by for example adding tests, and refactoring the code to make it more robust? If so, what procedure should I follow so that my changes end up in the repository?


@rgommers wrote on 2011-03-28

That would be great!

The easiest way to contribute is to work in git, as described in (just replace numpy with scipy). For straightforward bug fixes, extra tests, documentation improvements, etc. you can just do some work, push it to your github account and then send a pull request. For new features it is best to first discuss it on the mailing list.

If you're not familiar with git it's also possible to open tickets and attach patches, but review of those may be slower because that's more work for other developers.

If you already have ideas on where to start, just dig in I'd say. You can also look at open tickets for things that need fixing.


trac user sickbock wrote on 2011-04-10

Today I downloaded the SciPy source tree and tried to run the tests before I start to modify code. However, I could not get it to run; it seems I have to run
"python build" first. This is problematic, because this requires numpy >= 1.4, which is not yet in the Ubuntu repositories. I could try to do a source install of Numpy, but I am afraid I'll then find yet another dependency I'll have to resolve.

Is there a way to test the statistic functions without building all of scipy? If not, is there a guide or howto on how to get started with scipy development?


@rgommers wrote on 2011-04-10

Numpy is easier to build then Scipy (it has no C++ or Fortran code) and has no hard dependencies. It will be much faster if you have ATLAS installed though. To run the tests for both numpy and scipy you need nose (apt-get python-nose).

As described at, you can install the prerequisites for numpy/scipy with the following on Ubuntu:

sudo apt-get install gcc g77 python-dev atlas3-base-dev

Then it is just a matter of

python install

for numpy.

For scipy you can do the same, but if you are going to do development I would recommend an in-place install, which is described at

Then you can just modify functions in the source tree, and you'll see those changes on import.

Finally, you can work from just the downloaded source as you tried, but it will quickly pay off to learn how to use git. Without a version control system you will have problems generating patches to contribute back.


@josef-pkt wrote on 2011-04-10

In the long run it is worth setting up the development environment as Ralf described.

However, scipy.stats is pure python (except for part of distributions.vonmises, and kde), so when I got started with scipy.stats, I just made a separate install of scipy and started to edit the source directly. No recompiling is necessary.

It's possible then to create diffs to the original, but this loses having the changes under source control which is easier now with a decentralized version control system.


@rgommers wrote on 2011-04-10

That's true Josef, but since he has to install numpy and scipy from source anyway, the overhead of a proper in-place install is near-zero.


@rgommers wrote on 2012-07-10

Documentation issue fixed by #260


Milestone changed to 0.12.0 by @rgommers on 2012-07-10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.