Bugs item #1585977, was opened at 2006-10-27 13:06
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=453021&aid=1585977&group_id=48422

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: some floating point values are being altered

Initial Comment:
I am using
        Python 2.3.5 (#2, Mar  6 2006, 10:12:24) [GCC 4.0.3 20060304 
(prerelease) (Debian 4.0.2-10)] on linux2
        I do not know which version of RPy I am using;  how can I find 
that information?
        I also do not know which version of R I am controlling with RPy;  
how can I find that?
        The manually-controlled R I'm using is R version 1.0 (v2004-10
-14) on Mac OSX 10.3.9.

In a nutshell, it appears that some floating point values are being 
altered, either on the way from Py to R or back.

I am calling the R function ks.test from RPy, and occasionally I get 
negative p-values, which is not possible.  When I perform the identical 
command in R manually, I do not get the same result.  Further 
investigation showed other cases where the answers were different, but 
I will stick with this example.

----

In R:

data844 = 
c(0.98326834745,0.98371832020,0.98390990837,0.98410972477,0.
98448770184,0.98459213417,0.98838426859,0.98853557083,0.988
76263763,0.98905877724,0.98989187920)
ks.test(data844,"punif")

output:

                One-sample Kolmogorov-Smirnov test

        data:  data844
        D = 0.9833, p-value = 1.158e-09
        alternative hypothesis: two.sided

----

In python:

from rpy import *
data844 = 
[0.98326834745,0.98371832020,0.98390990837,0.98410972477,0.9
8448770184,0.98459213417,0.98838426859,0.98853557083,0.9887
6263763,0.98905877724,0.98989187920]
r.ks_test(data844,"punif")

output:

        {'data.name': ['c(0.98326834745, 0.9837183202, 
0.98390990837, 0.98410972477, ', '0.98448770184,
                              0.98459213417, 0.98838426859, 
0.98853557083, 0.98876263763, ', '0.98905877724,                
              0.9898918792)'],
        'alternative': 'two.sided',
        'method': 'One-sample Kolmogorov-Smirnov test',
        'p.value': -2.2204460492503131e-16,                          <----- 
note difference from 1.158e-09
        'statistic': {'D': 0.98326834745000002}}

----

Note that my input vector contains highly precise values.  One guess is 
that the data going into R is truncated to less precision.  The problem 
with that theory is that, mathematically, we should never expect ks.test 
to produce a negative p-value.  But I can't vouch for the fact that R will 
never do that.

My second guess is that the result somehow gets mis-converted on the 
way back to python.  This would be acceptable if the sign didn't 
change.

Are there any simple tests you can suggest I do that would help me 
figure out where the error is introduced?  I read the manual section 
(manual version 0.3.3, not necessarily in sync with the installed version 
here) on type conversion and I didn't see any mention of floats other 
than with respect to NaN and list-vs-tuple.

I can live with some conversion error.  The problem I have right now is 
that it's difficult to trust the results I'm getting, so I'm trying to figure 
out where the problem is, if it's something I can correct for, or detect, 
or what have you.

Thanks for any help,
Bob H


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=453021&aid=1585977&group_id=48422

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to