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