Rolf Turner wrote:
> On 28/03/2010, at 11:50 AM, Ben Bolker wrote:
> 
>> Gang Chen <gangchen6 <at> 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 <- length(x)
>>  mean((x-mx)^2)*n/(n-1)
>> }
> 
>       <SNIP>
> 
> Don't you want variances to be positive (non-negative) reals?
> 
> IIRC the population variance of a complex random variable is
> 
>       E(|X - mu|^2) not E((X - mu)^2)
> 
> So shouldn't your complex.var function have Mod(x-mx)^2 where
> you currently have (x-mx)^2 ???
> 
>       cheers,
> 
>               Rolf

  Probably.  To be honest, I wasn't thinking about it that carefully.
It crossed my mind to wonder what the appropriate definition was of the
variance for complex numbers, but I didn't bother to go find out.
   I guess it goes to show (yet again) that advice may be worth what you
pay for it ...


  cheers
    Ben

Attachment: signature.asc
Description: OpenPGP digital signature

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to