(and perhaps I should mention, you get the same pattern with moment(r,4) kurtosis(r) and mean(r.^4), presumably for the same reasons)
Difference between third moment, skewness and E(x^3)
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Fergus Fettes
el 28 de Mzo. de 2017
Comentada: Daniel Schiller
el 19 de Sept. de 2019
Can someone please explain why there is such a difference between skewness, the third moment and E(x^3), as in the following code:
mu = 0;
sigma = 1;
skew = 3;
kurt = 15;
r = pearsrnd(mu, sigma, skew, kurt, 10000, 1);
moment(r,3)
skewness(r)
mean(r.^3)
I know that the moment function computes a central moment, which is why I set mu to zero. Similarly skewness computes a standardized moment, which is why I set sigma to one. Under these circumstances, they should be the same, no?
The difference between the third moment and the expectation of the r cubed is acceptable, but the skewness varies much more, in some cases considerably.
Respuesta aceptada
the cyclist
el 28 de Mzo. de 2017
Editada: the cyclist
el 28 de Mzo. de 2017
The output is within expected sample error of these statistics (assuming you are seeing roughly the same output as I am).
" Note: Because r is a random sample, its sample moments, especially the skewness and kurtosis, typically differ somewhat from the specified distribution moments. pearsrnd uses the definition of kurtosis for which a normal distribution has a kurtosis of 3. Some definitions of kurtosis subtract 3, so that a normal distribution has a kurtosis of 0. The pearsrnd function does not use this convention."
Try cranking up your number of trials, and you'll see that they converge:
mu = 0;
sigma = 1;
skew = 3;
kurt = 15;
rng 'default'
NT = 10000000;
r = pearsrnd(mu, sigma, skew, kurt, NT, 1);
moment(r,3)
skewness(r)
mean(r.^3)
gives output
ans =
3.0077
ans =
3.0047
ans =
3.0075
3 comentarios
the cyclist
el 29 de Mzo. de 2017
Actually, I think the answer you provided to your own question is better than mine. I suggest you unaccept mine and accept your own.
There are a fair number of questions on this forum where people don't understand that a sample will not always have the exact moments as the inputs. But your question was actually a little more subtle, and your answer is more thorough.
Más respuestas (1)
Fergus Fettes
el 29 de Mzo. de 2017
1 comentario
Daniel Schiller
el 19 de Sept. de 2019
Thank you for that "code digging" research. It took me some hours today to understand what was going on with my data ... and now your anwers explained it to me.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!