avatarzhang / python-statlib

Automatically exported from code.google.com/p/python-statlib
Other
0 stars 0 forks source link

llinregress can't handle data with perfect correlation. #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

>>> from statlib.stats import llinregress
>>> def f(x):
...   return .3 * x + 7.2
... 
>>> xs = [1.1, 3, 2, 17]
>>> ys = [f(x) for x in xs]
>>> llinregress(xs, ys)
r is 1.0
taking log of -9.0076049212e+15
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "statlib/stats.py", line 1017, in llinregress
    z = 0.5*math.log(var)
ValueError: math domain error
>>> import statlib
>>> statlib.version
'1.1'

Hint: line numbers in the traceback might be wrong, because we have added
some printlines

Original issue reported on code.google.com by kamil.dw...@googlemail.com on 28 Nov 2008 at 4:29

GoogleCodeExporter commented 8 years ago
I added a fix for this, it is in the svn trunk, it is a quick fix, all tests 
pass.

It appears that we have several pending issues of this nature, where 'ideal' 
data
leads to problems, this will need to be addressed on a global basis.

Original comment by istvan.a...@gmail.com on 29 Nov 2008 at 12:53

GoogleCodeExporter commented 8 years ago
I have the same problem with lpearsonr now.

Original comment by jensp...@gmail.com on 16 Dec 2009 at 4:43

GoogleCodeExporter commented 8 years ago
This is a known problem - and it probably manifests itself in other ways as 
well. No
easy fix for now. 

Original comment by istvan.a...@gmail.com on 16 Dec 2009 at 1:58