What is the code?
5 ビュー (過去 30 日間)
古いコメントを表示
I want to generate random numbers. But i want it like this. for example i want to generate random numbers for The gamma distribution coefficient of skewness 2.
How can i do this?
0 件のコメント
採用された回答
José-Luis
2012 年 12 月 6 日
編集済み: José-Luis
2012 年 12 月 6 日
doc gamrnd
The skewness is a function of one of the two parameters of the distribution, that you can set as you see fit. You just need to set it so the skewness is two (look at the wikipedia article on the gamma distribution).
5 件のコメント
José-Luis
2012 年 12 月 13 日
編集済み: José-Luis
2012 年 12 月 13 日
From one of your comments.
When you do this:
i write this on matlab skewness = 2; scale = 1; shape = 2./sqrt(skewness); x=gamrnd(shape,scale) s=skewness(x)
Skewness becomes a variable, and overshadows the built-in skewness function in Matlab. It is good practice not to do that, as problems as the one got might pop-up (you think you are calling a function but you are in fact trying to access a variable).
After clearing your work space to make sure there is no variable called skweness in it, do this instead:
ske = 2;
sca = 1;
shap = 1/sqrt(2);
x = gamrnd(shap,sca,[1000 1]);
your_skew = skewness(x);
Please accept an answer if it helped you.
その他の回答 (1 件)
Jonathan Sullivan
2012 年 12 月 6 日
skewness is simple 2 divided by the square root of the shape parameter for gamma distributions. Here's an example.
skewness = 2;
scale = 1;
shape = 2./sqrt(skewness);
gamrnd(shape,scale)
9 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!