Re: Puzzled by the "Variance"
- To: mathgroup at smc.vnet.net
- Subject: [mg86544] Re: Puzzled by the "Variance"
- From: "Nasser Abbasi" <nma at 12000.org>
- Date: Thu, 13 Mar 2008 04:34:34 -0500 (EST)
- References: <fr8b97$h2s$1@smc.vnet.net>
- Reply-to: "Nasser Abbasi" <nma at 12000.org>
"Elements" <philyer at gmail.com> wrote in message news:fr8b97$h2s$1 at smc.vnet.net... > Greeting all > I'm puzzled by the function "Variance". We can learn how to calculate > variance from this page:http://mathworld.wolfram.com/SampleVariance.html. > For example, calculate the sample variance of {1,2,3}. the average of > {1,2,3} is 2, then the variance should be ((1-2)^2+(2-2)^2+(3-2)^2)/3=2/3. > But mathematica gives that: > > In[10]:= Variance[{1.0,2.0,3.0}] > Out[10]= 1. > > Why?? > -- > Best Wishes! > Yours Sincerely > > Mathematica uses the assumption that the data is a sample (size is small), hence it gives the sample variance, not population variance. The formula in this case changes. You need to divide by (n-1) not (n) where n is the sample size. In[5]:= r = {1., 2., 3.}; Variance[r] Out[6]= 1. In[13]:= m = Mean[r]; n = Length[r]; Sum[(r[[i]] - m)^2, {i, 1, n}]/(n - 1) Out[15]= 1. Nasser