[Numpy-tickets] [NumPy] #638: var should take absolute value for complex numbers.
NumPy
numpy-tickets@scipy....
Sat Dec 29 22:17:35 CST 2007
#638: var should take absolute value for complex numbers.
-------------------------+--------------------------------------------------
Reporter: akumar | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 1.0.5
Component: numpy.core | Version: none
Severity: normal | Resolution:
Keywords: var complex |
-------------------------+--------------------------------------------------
Comment (by akumar):
Replying to [ticket:638 akumar]:
> Hi!
>
> I was just wondering why numpy.var gives me complex variances for
complex numbers.
>
> e.g.
>
> {{{
> h1 = (randn(1000,1) + 1j *randn(1000,1)) / sqrt(2)
> var(h1)
> }}}
> gives: {{{ (-0.00757596036094-0.0234608549341j) }}}
>
> While I actually expect the output to be similar to that which is from
> {{{
> var(square(abs(h1)))
> }}}
Wrong! Actually, it should be {{{ mean(square(abs(h1))) }}}
which gives: {{{ 995184304741 }}}
Thanks.
Kumar
--
Ticket URL: <http://scipy.org/scipy/numpy/ticket/638#comment:1>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.
More information about the Numpy-tickets
mailing list