Generate random number from inverse gamma distribution

조회 수: 2 (최근 30일)
khatereh
khatereh 2012년 5월 27일
댓글: Kasi Vemalaiah 2021년 3월 8일
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

답변 (1개)

Tom Lane
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
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

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by