Why, when I calculate the skewness of a series with constants, do I not get NaN?
5 ビュー (過去 30 日間)
古いコメントを表示
Dear Matlab community,
I have a simulation of normally distributed numbers with a mean of 76 and a standard deviation of 0, which describes a series of constant numbers with the value 76. To this simulation, I apply a function that also yields constants and, therefore, its skewness should be also NaN. Why, when I calculate their skewness, do I not get NaN but 1? How do I correct this error?
Thanks in advance!
Np=20;
cb=2;
ab = 30*(Np/100)^(cb-1);
n=100;
Qd = normrnd(76,0,n,1);
Pw=ab*((Qd/Np).^(cb-1));
skewness(Pw)
skewness(Qd)
var(Qd)
0 件のコメント
採用された回答
Cris LaPierre
2021 年 10 月 11 日
I suspect this has to do with how floating point numbers are stored in a computer. 76 can be stored exactly as is, but 22.8000 is not exactly 22.8 in your computer. If you round Pw, you will see the skewness is also NaN.
format long
Np=20;
cb=2;
ab = 30*(Np/100)^(cb-1);
Qd = normrnd(76,0,100,1);
Pw=ab*((Qd/Np).^(cb-1));
Pw(1)
skewness(Pw)
var(Pw)
skewness(round(Pw))
skewness(Qd)
var(Qd)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Descriptive Statistics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!