Question: Central Moment of order 2 doesn't equal the Variance

I found this strange result:
When the central moment of order 2 and the variance are assessed on a sample of a random variable, they don't return the same value.

Let S be the sample, N its size and M its empirical mean.  The difference comes from the fact that 

  • Variance(S)               = add( (S[n]-M)^2, n=1..N) / (N-1)
  • CentralMoment(S, 2) = add( (S[n]-M)^2, n=1..N) / N

By definition the variance of a random variable X is its 2nd order central moment.
This definition should also apply when these statistics are calculated on a sample of X.

It seems to me this is a mistake.
 

restart:

with(Statistics):

N := 100:

# Example 1

U := RandomVariable(BetaDistribution(3, 2)):
CentralMoment(U, 2, numeric);
Variance(U, numeric);

print():
S := Sample(U, N):
CentralMoment(S, 2);
Variance(S);

0.4000000000e-1

 

0.4000000000e-1

 

 

HFloat(0.05053851854005207)

 

HFloat(0.05104900862631522)

(1)

# Example 2

V := RandomVariable(Normal(3, 2)):
CentralMoment(V, 2, numeric);
Variance(V, numeric);

print():

S := Sample(V, N):
CentralMoment(S, 2);
Variance(S)

4.

 

4.

 

 

HFloat(3.7514118336684517)

 

HFloat(3.7893048824933824)

(2)

# Examples revisited

S := Sample(U, N):
CentralMoment(S, 2);
Variance(S)*(N-1)/N;
print():
S := Sample(V, N):
CentralMoment(S, 2);
Variance(S)*(N-1)/N
 

HFloat(0.03346262243902275)

 

HFloat(0.03346262243902278)

 

 

HFloat(4.159851396769612)

 

HFloat(4.159851396769612)

(3)

 


 

Download StrangerThings.mw

Please Wait...