Skip to content

np.median on a complex array return incorrect value for the imaginary part #12943

Description

@flomertens

Calling np.median on a complex array return a complex number with correct real part, but incorrect imaginary part. Calling np.median on the real and imaginary part of the complex array separately return the correct values.

Reproducing code example:

d = (1 + 1j) + np.random.randn(10000) + 1j * np.random.randn(10000)
print 'median(d) : %.3f + %.3f i' % (np.median(d).real, np.median(d).imag)
print 'median(d.real): %.3f' % np.median(d.real)
print 'median(d.imag): %.3f' % np.median(d.imag)

median(d) : 1.002 + 0.124 i
median(d.real): 1.002
median(d.imag): 0.998

Numpy version: 1.15.4

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions