How do I generate a random number with beta distribution?
조회 수: 17 (최근 30일)
이전 댓글 표시
Ana Carolina da Silva Pacheco
2021년 4월 20일
댓글: Ana Carolina da Silva Pacheco
2021년 4월 21일
I have a variable with the PDF:
PDF = C . ((f - LB)/D)^alpha . ((UB - f)/D)^beta
Where:
C = 37337
alpha = 3
beta = 813,21
LB (lower bound) = 60000
UB (upper bound) = 2000000
D = UB - LB = 1940000
How do I generate a random number based on it?
댓글 수: 0
채택된 답변
Andrew Newell
2021년 4월 20일
You can use the function betarnd, but you'll need to do some normalizing to get it in the standard form used by MATLAB (see Beta distribution). If you define , then x is in the interval as required, so this should generate a suitable number:
a = alpha+1;
b = beta+1;
r = betarnd(a,b);
your_random_number = r*D+LB;
댓글 수: 3
Andrew Newell
2021년 4월 20일
Because in MATLAB's definition of the beta distribution, the exponents are and . So that gives you back and .
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!