jackscott / python-statlib

Exported from google.code, needed to get this crusty code working in a modern world
https://archive.org/web/
Other
0 stars 0 forks source link

Linear regression gives error for monotonous series #9

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I've been using this very nice lib for its linear regression, which I use a
small application of mine. However, similar to an issue that is reported
before and marked as solved, I get error when the y_range is monotonous.

What steps will reproduce the problem?
>>> import statlib.stats
>>> stats.linregress([1,2,3,4,5], [1,2,3,4,5])
(1.0, 0.0, 1.0, 1.2004217548646513e-30, 0.0)
>>> stats.linregress([1,2,3,4,5], [1,1,1,1,1])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-i686/egg/statlib/stats.py", line 288, in __call__
  File "build/bdist.linux-i686/egg/statlib/stats.py", line 1013, in llinregress
ZeroDivisionError: float division
>>> statlib.version
'1.1'

Expected: slope = 0, intercept = 1, r = 1

What version of the product are you using? On what operating system?
OpenSUSE 10.3 x86_64

Original issue reported on code.google.com by ercan.yu...@gmail.com on 30 Mar 2009 at 1:39