MATLAB Answers

How do I generate a random number with beta distribution?

39 ビュー (過去 30 日間)
Ana Carolina Pacheco
Ana Carolina Pacheco 2021 年 4 月 20 日 1:24
コメント済み: Ana Carolina Pacheco 2021 年 4 月 21 日 0:20
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?

採用された回答

Andrew Newell
Andrew Newell 2021 年 4 月 20 日 1:59
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 件のコメント
Ana Carolina Pacheco
Ana Carolina Pacheco 2021 年 4 月 21 日 0:20
Got it, thank you, that solved my problem.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by