data-apis / array-api

RFC document, tooling and other content related to the array API standard
https://data-apis.github.io/array-api/latest/
MIT License
211 stars 44 forks source link

RFC: add support for complex input to `mean` #846

Open lucascolley opened 6 days ago

lucascolley commented 6 days ago

x-ref https://github.com/data-apis/array-api-extra/pull/10/files#r1776010210

While implementing a simple cov in array-api-extra (https://github.com/data-apis/array-api-extra/pull/10) I found that xp.mean does not support complex input. @kgryte suggested opening an issue over here as the arithmetic mean is well-defined for complex numbers.

asmeurer commented 6 days ago

Was there a reason for this or was it just an accidental omission? Mean is well-defined for complex numbers (https://en.wikipedia.org/wiki/Complex_random_variable), and should be easy to implement since you either just apply the real kernel formula directly to complex data types, or take the means of the real and imaginary parts separately.

kgryte commented 6 days ago

I believe an omission and thus far no R&D whether supported across all array libraries.