help-octave
[Top][All Lists]

## Re: Covariance Question

 From: Mike Miller Subject: Re: Covariance Question Date: Sun, 2 Mar 2003 13:49:32 -0600 (CST)

```On Sun, 2 Mar 2003, Dirk Eddelbuettel wrote:

> octave2.1:1> x=[3;1;3;9];
> octave2.1:2> y=[4;4;8;8];
> octave2.1:3> cov(x,y)*(length(x)-1)/length(x)
> ans = 4
>
> The difference depends on whether you "know" that your data comes from
> a sample versus a population. See e.g.
>

Right.  It's the N v. N-1 effect.  Use of N produces the maximum
likelihood estimator for multivariate normal data.  It has good properties
and is, in some ways, superior to use of N-1.  That's another reason to
use N sometimes, not just because the entire population is known.  Still,
N-1 is used much more often, and Octave uses N-1.  I think it's the right
choice for the default behavior of the cov function.  It's also what
MATLAB does.

Mike

-------------------------------------------------------------
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
-------------------------------------------------------------

```