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

조회 수: 2 (최근 30일)
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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by