[Numpy-tickets] [NumPy] #638: var should take absolute value for complex numbers.

NumPy numpy-tickets@scipy....
Sun Dec 30 01:31:48 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 kumanna):

 Replying to [comment:5 rkern]:
 > Hmm. You'll note, though, that the result is a matrix, not a single real
 or complex value. It is the result of finding the full covariance matrix
 of the 2-vector (real, imag). You really want to use {{{cov()}}}, not
 {{{var()}}}. Probably, we should just disallow complex values for
 {{{var()}}}.

 Well, that is true. However, should you wish to be somewhat compatible
 with Matlab or Octave, you wouldn't want to do that.

 And, for some reason, it doesn't seem to do the same thing:

 {{{
 h1 = (randn(1000) + 1j *randn(1000)) / sqrt(2)
 cov(h1)
 Out: array(0.46705704279061899)
 }}}

 Huh?

 {{{
 mean(multiply(h1, conj(h1))) - multiply(mean(h1), conj(mean(h1)))
 Out: (0.947439186641+0j)
 }}}

 Am I going wrong somewhere?

 Thanks.

 Kumar

-- 
Ticket URL: <http://scipy.org/scipy/numpy/ticket/638#comment:6>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list