Generate random number from inverse gamma distribution
5 ビュー (過去 30 日間)
古いコメントを表示
Hi, I want to get the sample from the inverse gamma distribution with two parameter a and b and I am wondering how I can do that in matlab? Please help me ! Thanks
0 件のコメント
回答 (1 件)
Tom Lane
2012 年 5 月 27 日
If I understand the inverse gamma correctly, you can generate from x=gamrnd(a,1./b) and then take y=1./x. This would require the Statistics Toolbox.
3 件のコメント
Zhiyong Yang
2018 年 11 月 27 日
Hi, Jonathan
Have you solved this problem?I have compared the pdf curves obtained by ksdensity method of samples draw by the mentioned way using gamrnd function and by analytical solution using the equation of inverse-gamma pdf. It is shown as the alpha is smaller than 2, the mentioned way cannot sample well. Please see the attached figure where symbols represent pdf from ksdensity method and lines represent pdf from analytical solutoin. ![untitled.bmp](https://www.mathworks.com/matlabcentral/answers/uploaded_files/197080/untitled.bmp)
![untitled.bmp](https://www.mathworks.com/matlabcentral/answers/uploaded_files/197080/untitled.bmp)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!