Creates an array of beta random deviates based on the supplied
two parameters. The general syntax for randbeta
is
y = randbeta(alpha, beta)
where alpha
and beta
are the two parameters of the
random deviate. There are three forms for calling randbeta
.
The first uses two vectors alpha
and beta
of the same
size, in which case the output y
is the same size as both
inputs, and each deviate uses the corresponding values of alpha
and beta
from the arguments. In the other forms, either
alpha
or beta
are scalars.
The probability density function (PDF) of a beta random variable is
for
x
between 0 and 1. The function B(a,b)
is defined so
that the integral of f(x)
is 1.
Here is a plot of the PDF of a beta random variable with a=3
,
b=7
.
--> a = 3; b = 7; --> x = (0:100)/100; t = x.^(a-1).*(1-x).^(b-1); --> t = t/(sum(t)*.01); --> plot(x,t);
which is plotted as
If we generate a few random deviates with these values,
we see they are distributed around the peak of roughly
0.25
.
--> randbeta(3*ones(1,5),7*ones(1,5)) ans = <float> - size: [1 5] Columns 1 to 3 0.22869696 0.29723001 0.24044843 Columns 4 to 5 0.32869500 0.22941548