1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>RANDBETA Beta Deviate Random Number Generator
</TITLE>
</HEAD>
<BODY>
<H2>RANDBETA Beta Deviate Random Number Generator
</H2>
<P>
Section: <A HREF=sec_random.html> Random Number Generation </A>
<H3>Usage</H3>
Creates an array of beta random deviates based on the supplied
two parameters. The general syntax for <code>randbeta</code> is
<PRE>
y = randbeta(alpha, beta)
</PRE>
<P>
where <code>alpha</code> and <code>beta</code> are the two parameters of the
random deviate. There are three forms for calling <code>randbeta</code>.
The first uses two vectors <code>alpha</code> and <code>beta</code> of the same
size, in which case the output <code>y</code> is the same size as both
inputs, and each deviate uses the corresponding values of <code>alpha</code>
and <code>beta</code> from the arguments. In the other forms, either
<code>alpha</code> or <code>beta</code> are scalars.
<H3>Function Internals</H3>
The probability density function (PDF) of a beta random variable
is
<P>
<DIV ALIGN="CENTER">
<IMG SRC="randbeta_eqn1.png">
</DIV>
<P>
for <code>x</code> between 0 and 1. The function <code>B(a,b)</code> is defined so
that the integral of <code>f(x)</code> is 1.
<H3>Example</H3>
Here is a plot of the PDF of a beta random variable with <code>a=3</code>,
<code>b=7</code>.
<PRE>
--> a = 3; b = 7;
--> x = (0:100)/100; t = x.^(a-1).*(1-x).^(b-1);
--> t = t/(sum(t)*.01);
--> plot(x,t);
</PRE>
<P>
which is plotted as
<P>
<DIV ALIGN="CENTER">
<IMG SRC="betapdf.png">
</DIV>
<P>
If we generate a few random deviates with these values,
we see they are distributed around the peak of roughly
<code>0.25</code>.
<PRE>
--> randbeta(3*ones(1,5),7*ones(1,5))
ans =
0.2777 0.0642 0.3305 0.5259 0.4003
</PRE>
<P>
</BODY>
</HTML>
|