Rev | Line | |
---|
[37] | 1 | function x = randbeta(a,b)
|
---|
| 2 | % RANDBETA Sample from Beta distribution
|
---|
| 3 | %
|
---|
| 4 | % X = RANDBETA(A,B) returns a matrix, the same size as A and B, where X(i,j)
|
---|
| 5 | % is sampled from a Beta(A(i,j),B(i,j)) distribution.
|
---|
| 6 | % A or B can be scalar when the other is a matrix, otherwise they must be
|
---|
| 7 | % the same size.
|
---|
| 8 |
|
---|
| 9 | if length(a) == 1
|
---|
| 10 | a = repmat(a,size(b));
|
---|
| 11 | elseif length(b) == 1
|
---|
| 12 | b = repmat(b,size(a));
|
---|
| 13 | end
|
---|
| 14 | x = randgamma(a);
|
---|
| 15 | x = x./(x + randgamma(b));
|
---|
Note: See
TracBrowser
for help on using the repository browser.