I want to test whether the skewness of the samples(from A:900*1 matrix) converge to 0 or not by using Montecarlo simulation.
Show older comments
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')
Answers (1)
Aditya
on 8 Sep 2023
0 votes
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 ‘randperm’ function. 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:
- https://in.mathworks.com/help/matlab/ref/randperm.html
- https://in.mathworks.com/help/stats/skewness.html
Hope this helps!
Categories
Find more on MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!