stats.zipf floating point warnings (Trac #1361) #1886

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

Comments

Projects
None yet
3 participants
@scipy-gitbot

Original ticket http://projects.scipy.org/scipy/ticket/1361 on 2011-01-15 by @rgommers, assigned to unknown.

The zipf tests in stats/test_discrete_basic.py were yielding floating point warnings for many (all?) methods. In 1c4ebaa the zipf tests were disabled.

zipf(4) was giving warnings, zipf(2) was failing according to a comment in the test file. The whole implementation should be reviewed.

@josef-pkt

This comment has been minimized.

Show comment
Hide comment
@josef-pkt

josef-pkt Sep 14, 2013

Member

gh-2857 adds test for moments
_stats uses special.errprint(0) ? never seen

The entire ._stats function can be deleted (not even worth a _stats_skip) because it just uses the generic calculation to go from moments to mvsk, AFAICS

zipf is largely based on special.zeta. Need to check where it runs into floating point problems

k**a by np.power(k, a) would be safer

from comments in test suite, some moments are inf if the shape parameter is small

Member

josef-pkt commented Sep 14, 2013

gh-2857 adds test for moments
_stats uses special.errprint(0) ? never seen

The entire ._stats function can be deleted (not even worth a _stats_skip) because it just uses the generic calculation to go from moments to mvsk, AFAICS

zipf is largely based on special.zeta. Need to check where it runs into floating point problems

k**a by np.power(k, a) would be safer

from comments in test suite, some moments are inf if the shape parameter is small

@josef-pkt

This comment has been minimized.

Show comment
Hide comment
@josef-pkt

josef-pkt Sep 14, 2013

Member

cross-ref PR gh-2841 was for continuous distribution

Member

josef-pkt commented Sep 14, 2013

cross-ref PR gh-2841 was for continuous distribution

@josef-pkt

This comment has been minimized.

Show comment
Hide comment
@josef-pkt

josef-pkt Sep 14, 2013

Member

Wikipedia doesn't have precise details on Zipf distribution (story is on Zipf law)
the test suite example with a=4 has (I guess) 4th moment = inf

Member

josef-pkt commented Sep 14, 2013

Wikipedia doesn't have precise details on Zipf distribution (story is on Zipf law)
the test suite example with a=4 has (I guess) 4th moment = inf

@josef-pkt

This comment has been minimized.

Show comment
Hide comment
@josef-pkt

josef-pkt Sep 14, 2013

Member

_munp needs to return inf for a-n <=1

>>> special.zeta(1,1)
inf
>>> special.zeta(0,1)
nan
>>> special.zeta(1.5,1)
2.6123753486854882
>>> special.zeta(1.01,1)
100.57794333849679
>>> special.zeta(1.0001,1)
10000.577222947541
>>> special.zeta(2,1)
1.6449340668482266
Member

josef-pkt commented Sep 14, 2013

_munp needs to return inf for a-n <=1

>>> special.zeta(1,1)
inf
>>> special.zeta(0,1)
nan
>>> special.zeta(1.5,1)
2.6123753486854882
>>> special.zeta(1.01,1)
100.57794333849679
>>> special.zeta(1.0001,1)
10000.577222947541
>>> special.zeta(2,1)
1.6449340668482266
@rgommers

This comment has been minimized.

Show comment
Hide comment
@rgommers

rgommers Oct 12, 2013

Member

Fixed in gh-2904.

Member

rgommers commented Oct 12, 2013

Fixed in gh-2904.

@rgommers rgommers closed this Oct 12, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment