[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: var(x) and std(x)
From: |
Paul Kienzle |
Subject: |
Re: var(x) and std(x) |
Date: |
Tue, 12 Nov 2002 16:15:49 -0500 |
User-agent: |
Mutt/1.2.5.1i |
Oops. What about complex numbers?
It ought to be:
var(x+iy) = var(x) + var(y)
which is equivalent to:
y = abs ( (x - mean(x)) * (x - mean(x))' ) / (n-1)
The abs() is necessary because machine precision won't necessarily
yield a real value from x * conj(x).
However one web page gives the following formula:
var(x+iy) = 1/2 * (var(x) + var(y))
and says that the factor of 1/2 is controversial. Anyone have
an authoritative definition?
Paul Kienzle
address@hidden
On Tue, Nov 12, 2002 at 01:03:13PM -0600, John W. Eaton wrote:
> On 12-Nov-2002, Paul Kienzle <address@hidden> wrote:
>
> | Index: var.m
> | ===================================================================
> | RCS file: /cvs/octave/scripts/statistics/base/var.m,v
> | retrieving revision 1.6
> | diff -c -r1.6 var.m
> | *** var.m 2002/09/26 22:48:24 1.6
> | --- var.m 2002/11/12 18:30:44
> | ***************
> | *** 40,48 ****
> | y = 0;
> | elseif ((nr == 1) || (nc == 1))
> | n = length (x);
> | ! y = (sumsq (x) - abs(sum(x))^2 / n) / (n - 1);
> | else
> | ! y = (sumsq (x) - abs(sum(x)).^2 / nr) / (nr - 1);
> | endif
> |
> | endfunction
> | --- 40,48 ----
> | y = 0;
> | elseif ((nr == 1) || (nc == 1))
> | n = length (x);
> | ! y = sumsq (x - sum (x) / n) / (n - 1);
> | else
> | ! y = sumsq (x - ones (nr, 1) * (sum (x) / nr) ) / (nr - 1);
> | endif
> |
> | endfunction
>
> I applied this patch.
>
> Thanks,
>
> jwe
>
>
>
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
>
> Octave's home on the web: http://www.octave.org
> How to fund new projects: http://www.octave.org/funding.html
> Subscription information: http://www.octave.org/archive.html
> -------------------------------------------------------------
>
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------