RANDBETA Beta Deviate Random Number Generator

Section: Random Number Generation

Usage

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.

Function Internals

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.

Example

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 = 
    0.2777    0.0642    0.3305    0.5259    0.4003