I want to test whether the skewness of the samples(from A:900*1 matrix) converge to 0 or not by using Montecarlo simulation.

3 ビュー (過去 30 日間)
Chris
Chris 2022 年 10 月 30 日
回答済み: Aditya 2023 年 9 月 8 日
Hi,
I want to test whether the skewness of the samples(from A:900*1 matrix) converge to 0 or not by using Montecarlo simulation.
In this case, what codes do I have to revise...?
load('file')
nn=100; %effective sample sizes
for n=1:1000;
~~~~~~~~~~~
ss(n)=std(r);
m(n)=mean(r);
med(n)=median(r);
nu(n)=numel(r)
skew_FP(n) = sum((r-m(n)).^3)/(length(n)-1)/ss(n).^3
end
hist(skew_FP())
xlabel('Skew_FP()')
ylabel('Frequency')

回答 (1 件)

Aditya
Aditya 2023 年 9 月 8 日
Hello Chris,
I have reviewed your code and would like to suggest some changes to improve it:
  • Before the for loop, please define the skew_FP array as follows: skew_FP = zeros(1000, 1);. This will initialize the array with zeros to store the skewness values
  • To generate the r array, you can use the randpermfunction. It allows you to randomly select k samples from the range of n. For example: r = randperm(n, k);
  • Instead of manually calculating the skewness, you can utilize the built-in MATLAB function skewness. This function will compute the skewness of the r array directly. You can assign the result to skew_FP(n) as follows: skew_FP(n) = skewness(r);
For further details on these functions, please refer to the following documentation:
Hope this helps!

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by