Re: [R] Calculate variance/covariance with complex numbers

2010-03-28 Thread Jim Lemon
On 03/29/2010 04:17 AM, Charles C. Berry wrote: ... Argh! Sorry for the 'thinko' (like a 'typo', but a misapplication of the brain rather than the fingers)! Well, a typo is the _result_ of a misapplication of the fingers to a keyboard, so I would expect that if the result of thinking can be cal

Re: [R] Calculate variance/covariance with complex numbers

2010-03-28 Thread Ben Bolker
Rolf Turner wrote: > On 28/03/2010, at 11:50 AM, Ben Bolker wrote: > >> Gang Chen gmail.com> writes: >> >>> Anybody knows what functions can be used to calculate >>> variance/covariance with complex numbers? var and cov don't seem to >>> work: >> How about: >> >> y <- complex(real=5:1,imag=2:6)

Re: [R] Calculate variance/covariance with complex numbers

2010-03-28 Thread Charles C. Berry
On Sun, 28 Mar 2010, Gang Chen wrote: Thanks a lot for the help, Ben Bolker and Chuck! Chuck, it seems your version needs a little modification. Instead of this: xri <- matrix(rnorm(1)+1i*rnorm(1),nc=2) crossprod(xri-colMeans(xri))/(nrow(xri)-1) it seems to me it should be this (may

Re: [R] Calculate variance/covariance with complex numbers

2010-03-28 Thread Ben Bolker
Gang Chen gmail.com> writes: > > Thanks a lot for the help, Ben Bolker and Chuck! > > Chuck, it seems your version needs a little modification. Instead of this: > > > xri <- matrix(rnorm(1)+1i*rnorm(1),nc=2) > > crossprod(xri-colMeans(xri))/(nrow(xri)-1) > > it seems to me it should b

Re: [R] Calculate variance/covariance with complex numbers

2010-03-27 Thread Gang Chen
Thanks a lot for the help, Ben Bolker and Chuck! Chuck, it seems your version needs a little modification. Instead of this: > xri <- matrix(rnorm(1)+1i*rnorm(1),nc=2) > crossprod(xri-colMeans(xri))/(nrow(xri)-1) it seems to me it should be this (maybe there is a more elegant modification

Re: [R] Calculate variance/covariance with complex numbers

2010-03-27 Thread Charles C. Berry
On Sat, 27 Mar 2010, Gang Chen wrote: Anybody knows what functions can be used to calculate variance/covariance with complex numbers? var and cov don't seem to work: How about? xri <- matrix(rnorm(1)+1i*rnorm(1),nc=2) crossprod(xri-colMeans(xri))/(nrow(xri)-1) HTH, Chuck a

Re: [R] Calculate variance/covariance with complex numbers

2010-03-27 Thread Ben Bolker
Gang Chen gmail.com> writes: > > Anybody knows what functions can be used to calculate > variance/covariance with complex numbers? var and cov don't seem to > work: How about: y <- complex(real=5:1,imag=2:6) z <- complex(real=1:5,imag=6:10) complex.var <- function(x) { mx <- mean(x) n <-

[R] Calculate variance/covariance with complex numbers

2010-03-27 Thread Gang Chen
Anybody knows what functions can be used to calculate variance/covariance with complex numbers? var and cov don't seem to work: > a 1 V1 0.00810014+0.00169366i V2 0.00813054+0.00158251i V3 0.00805489+0.00163295i V4 0.00809141+0.00159533i V5 0.00813976+0.00161850i > var(a)