[
https://issues.apache.org/jira/browse/HIVE-3455?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13458414#comment-13458414
]
Edward Capriolo commented on HIVE-3455:
---------------------------------------
I think your data file must be in error.
{noformat}
FROM (
select inline ( array( struct(1,2), struct(2,4), struct(3,6) ) ) as (x,y) from
dummy limit 3
) b select corr(b.x,b.y)
OK
0.9999999999999999
Time taken: 9.436 seconds
{noformat}
and
{noformat}
hive> FROM (
>
> select inline ( array( struct(1,3), struct(2,2), struct(3,1) ) ) as (x,y)
from dummy limit 3
>
> ) b select corr(b.x,b.y) ;
Mapred Local Task Succeeded . Convert the Join into MapJoin
OK
-0.9999999999999999
Time taken: 10.842 seconds
{noformat}
Looks good compared to.
http://my.safaribooksonline.com/book/databases/sql/9780596155322/ansi-sql-aggregate-functions/id3490390
Please re-open if I am wrong.
> ANSI CORR(X,Y) is incorrect
> ---------------------------
>
> Key: HIVE-3455
> URL: https://issues.apache.org/jira/browse/HIVE-3455
> Project: Hive
> Issue Type: Bug
> Components: UDF
> Affects Versions: 0.7.1, 0.8.0, 0.8.1, 0.9.0, 0.10.0
> Reporter: Maxim Bolotin
>
> A simple test with 2 collinear vectors returns a wrong result.
> The problem is the merge of variances, file:
> http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFCorrelation.java?revision=1157222&view=markup
> lines:
> 347: myagg.xvar += xvarB + (xavgA-xavgB) * (xavgA-xavgB) * myagg.count;
> 348: myagg.yvar += yvarB + (yavgA-yavgB) * (yavgA-yavgB) * myagg.count;
> the correct merge should be like this:
> 347: myagg.xvar += xvarB+(xavgA - xavgB)*(xavgA-xavgB)/myagg.count*nA*nB;
> 348: myagg.yvar += yvarB+(yavgA - yavgB)*(yavgA-yavgB)/myagg.count*nA*nB;
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira