Command skewness(x) vs calculating sample skewness by hand

14 ビュー (過去 30 日間)
Benedikt Gasparic
Benedikt Gasparic 2018 年 10 月 28 日
編集済み: John D'Errico 2018 年 10 月 28 日
Task is to calculate sample skewness(x) by hand in Matlab to show that you understand the mathematical concept aka:
My solution was: skewness_x=((1/numel(x))*(sum((x-mean(x)).*(x-mean(x)).*(x-mean(x))))/(std(x)^3)) except this value is 3*10^-4 off the value which i get from skewness(x).
(x being a (1,300) vektor with 300 random values)
Did i make a mistake in my formula? Or does Matlab round somewhere?

採用された回答

John D'Errico
John D'Errico 2018 年 10 月 28 日
編集済み: John D'Errico 2018 年 10 月 28 日
This is not a rounding issue.
The answer is almost always to check the docs for the function in question.
doc skewness
If you do read that doc, in the algorithms section, you will quickly see that skewness does something slightly different. That difference probably comes about because of a degrees of freedom thing. Think of it like this: when you compute the SAMPLE standard deviation, it needs to use the mean, as if the mean were known. So a sample standard deviation (what you get from std(x,0), or just the default std(x)) has a factor if 1/sqrt(n-1) in there, instead of 1/sqrt(n). This is the classically seen difference between a population estimator versus a bias corrected sample standard deviation.
But when you compute skewness, it also uses the sample standard deviation. So skewness(x,0) needs to tweak those factors of n in the formula to give a bias corrected estimator.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by