Skip to content

Difference between ak.std() and np.std() #3628

@taehyounpark

Description

@taehyounpark

Version of Awkward Array

2.8.1

Description and code to reproduce

I'm seeing a NaN vs. finite-valued std() difference between NumPy and Awkward on the exact same array.

NumPy call: np.std(ak.to_numpy(ak.flatten(X)))
Awkward call: ak.std(ak.flatten(X))

Below are some example outputs:

  np.mean() = 1.0000672340393066
  ak.mean() = 1.0000670059867527
  np.std() = 2.9891753001720645e-05
  ak.std() = 0.0005289947633893411
  np.mean() = 0.9998437166213989
  ak.mean() = 0.9998438106560559
  np.std() = 0.0003517308796290308
  ak.std() = nan

The arrays contain float32's in both the numpy and awkward implementation. I'm surprised to see the large difference in std(), especially a case where nan is reported and not. There are no nan's in any of the arrays and I would expect a finite standard deviation value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions