You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Yibo Cai (Jira)" <ji...@apache.org> on 2021/02/23 11:02:00 UTC

[jira] [Commented] (ARROW-11567) [C++][Compute] Variance kernel has precision issue

    [ https://issues.apache.org/jira/browse/ARROW-11567?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17289011#comment-17289011 ] 

Yibo Cai commented on ARROW-11567:
----------------------------------

Numpy looks is using pariwise summation algorithm which has better precision.

numpy source code:
https://github.com/numpy/numpy/blob/ce82028409c1147a6df62d8f7437e0a9262ee2b7/numpy/core/src/umath/loops_utils.h.src#L78

pairwise summation:
https://en.wikipedia.org/wiki/Pairwise_summation

> [C++][Compute] Variance kernel has precision issue
> --------------------------------------------------
>
>                 Key: ARROW-11567
>                 URL: https://issues.apache.org/jira/browse/ARROW-11567
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: C++
>    Affects Versions: 3.0.0
>            Reporter: Yibo Cai
>            Assignee: Yibo Cai
>            Priority: Major
>
> For long arrays, variance kernel is not accurate compared with numpy. See below example.
> {noformat}
> In [1]: import numpy as np
> In [2]: import pyarrow.compute as pc
> In [3]: t = np.arange(321000, dtype='float')
> In [4]: np.var(t)
> Out[4]: 8586749999.916667
> In [5]: pc.variance(t)
> Out[5]: <pyarrow.DoubleScalar: 8586749999.899047>
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)