How to generate random numbers from a scaled beta PDF?

조회 수: 6 (최근 30일)
esperanta
esperanta 2020년 5월 23일
답변: Jeff Miller 2020년 5월 24일
Hello! I generated a scaled Beta PDF with parameters a=3, b=3, scaled in the interval [-0.5,0.5] by using the function Scaled_BetaPDF, whose output are the probabilities of each element in the interval. However, I am not sure how to generate one random number from such a distribution.
My code to generate the PDF:
X=-0.5:.1:0.5;
Scaled_BetaPDF(X, 3, 3, -0.5, 0.5)
Then, in order to generate a random number from this distribution, I tried the following codes (obviously wrong):
random(Scaled_BetaPDF(X, 3, 3, -0.5, 0.5))
which gave me the error "Error using random The NAME argument must be a distribution name.".
How can generate random numbers from a PDF that I create with a specific function?
Thanks

채택된 답변

Jeff Miller
Jeff Miller 2020년 5월 24일
Generate regular beta random numbers and then rescale them. I guess you want to generate randomly from the regular beta(3,3) distribution and then subtract 0.5.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Random Number Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by