help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: var(x) and std(x)


From: Michael Jachan
Subject: Re: var(x) and std(x)
Date: Tue, 12 Nov 2002 16:43:22 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.4.1) Gecko/20020508 Netscape6/6.2.3

Hi Anand!

This is not an error! There are 2 major ways to define estimators for variance (std. deviation). The one with 1/(N-1) as fore factor is an unbiased estimator, the other one is biassed with (N-1)/N. This follows from estimation theory, look into a good book about statistics to find out more...


Michael


Anand V wrote:

Hi,
  I have a doubt regarding the implementation of variance function var(x) in 
octave.It finds the variance as follows

function y = var(x)

  if (nargin != 1)
    usage ("var (x)");
  endif

  [nr, nc] = size (x);
  if (nr == 0 || nc == 0)
    error ("var: x must not be empty");
  elseif ((nr == 1) && (nc == 1))
    y = 0;
  elseif ((nr == 1) || (nc == 1))
    n = length (x);
    y = (sumsq (x) - sum(x)^2 / n) / (n-1);
  else
    y = (sumsq (x) - sum(x).^2 / nr) / (nr-1);
  endif

endfunction

It gives variance after averaging over n-1 samples, rather than averaging over n samples. for example, if we calculate the variance of x = [1,2,3] , it returns the value 1, instead of 2/3..This is because it finds 2/2 and not 2/3..The same is the case with std(x) also. Is it an error or is there any explanation for that?
Please correct me if I am wrong.

Thanks and Regards
Anand


_____________________________________________________________
Kerala's coolest community site ---> http://www.achayans.com

India's fastest growing Search Engine ->
http://www.indianindex.com

India's largest Online Matchmakers -->
http://www.indianalliance.com

_____________________________________________________________
Select your own custom email address for FREE! Get address@hidden w/No Ads, 6MB, 
POP & more! http://www.everyone.net/selectmail?campaign=tag



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




--
-----------------------------------------------------------
Michael Jachan
Institute of Communications and Radio-Frequency Engineering
Vienna University of Technology
A-1040 Vienna, Gusshausstr. 27/E389/111
address@hidden, ++43 1 58801 38914
www.nt.tuwien.ac.at/dspgroup/tfgroup/time.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
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]