Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

var and std of complex array should return Real #13309

Closed
stevengj opened this issue Sep 24, 2015 · 0 comments
Closed

var and std of complex array should return Real #13309

stevengj opened this issue Sep 24, 2015 · 0 comments
Labels
bug Indicates an unexpected problem or unintended behavior maths Mathematical functions

Comments

@stevengj
Copy link
Member

I noticed today with Julia 0.5 that var(rand(Complex128, 100)) gives a complex result (e.g. 0.1877618197855592 + 0.0im) even though the result is always real-valued by definition.

Furthermore, the var(iterable) definition is wrong for complex values since it is missing the requisite complex conjugations: invoke(var, (Any,), rand(Complex128, 100)) gives a completely different (complex) result (e.g. 0.02791245510174357 + 0.008222495005184707im).

The former is suboptimal, but the latter is definitely a bug.

(And the frustrating thing is that I feel like I've fixed this before, somewhere in the Julia 0.1-0.2 timeframe. If so, my fault for not putting in a regression test.)

@stevengj stevengj added bug Indicates an unexpected problem or unintended behavior maths Mathematical functions labels Sep 24, 2015
stevengj added a commit that referenced this issue Sep 29, 2015
fix #13309: return correct real value from var, varm, etc of complex arrays
stevengj added a commit that referenced this issue Sep 29, 2015
skumagai pushed a commit to skumagai/julia that referenced this issue Oct 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior maths Mathematical functions
Projects
None yet
Development

No branches or pull requests

1 participant