Recall the strong theorem of large numbers: let
be a sequence of
independent random variables having a common distribution and let
. Then with probability 1,
.
It follows that one way to estimate
is to simulate
from
and form the
arithmetic mean of the x’s as the estimate.
In general can estimate
by
where
are drawn
independently from
.
Suppose a random variable X has a beta distribution with parameters a,
b:
if ![]()
where
is called a Beta function.
We want to evaluate
. This is an
incomplete beta function which has been tabulated.
Alternatively define ![]()
Then 
So estimate
by simulating
from
and letting
.
This general procedure is called Monte Carlo Integration.
How do you draw random variables from
?
e.g.
then
is approximately
.
Note the examples in the book
–
generating
a random permutation
–
estimating
the number of distinct entries in a large set
The Inverse Transformation
Method (method 1)
Consider a random variable
with CDF
. Define a new random variable ![]()
. Then
~
.

Let
. Define a random variable
where F is a CDF. Then
F is the CDF of X.
Proof:
.
Thus, if we know how to invert
, we can simulate X by generating a random u ~ U(0,
1) and letting
.
Example:
Simulating a Weibull. For a Weibull random variable X have:
![]()
Then
is that value of X such that:
![]()

X generated in this fashion will have Weibull
distribution.
This method only works when
is invertible which
will not often be the case.
The rejection method (method 2)
Suppose there is a density
which is “close” to
the density
that we wish to
simulate from but it is much easier to simulate from
than
(e.g.
might be gamma and
Weibull). Then
provided c such that
for all x, we
can use
to get simulations
from
.

must have support at least as big as
.
Here is how it works:
Step 1 |
Simulate Y having density |
Step 2 |
If |
Claim: that the value X
has density function
.

The denominator does not involve x.
But
.
Since
, the number of
iterations until an acceptance will be geometric with mean c. Thus it is
important to choose
so that c is small.
However, a difficulty with the rejection method is that in many
applications, c is hard to compute. Often end up choosing c very
conservatively large thereby resulting in very high computational costs.
Sampling Importance
Resampling (method 3) (Rubin, 1987)
Again, assume there is a density
which is close to the density f that we
want to simulate from. Then to generate a sample of size n from f,
proceed as follows:
Each of the n x’s is drawn with possibility:
as ![]()
SIR is subject to the same problems as rejection sampling
but has the advantage that it converges provided
without explicitly
requiring
.
Example: (beta distribution)
Suppose want to simulate from
,
. We chose as our candidate (also called the “envelope”
distribution)
,
.
Then
is bounded iff ![]()
![]()
Use either rejection sampling or SIR.
If
then use ![]()
Can simulate from
by the inverse transformation
method:

So if ![]()
1.
Sum of 12 uniforms (approximate algorithm)
, ![]()
![]()
![]()
and X is approximately normal by Central Limit Theorem. This is a
fairly crude approximation but may be adequate for some applications.
First note that if
(i.e. Z ~ N(0,
1))
Then letting ![]()
, ![]()
(
)
Try candidate distribution
(i.e. exp(1))
Then 
(
since if
which is impossible )
So, the procedure is:
Note:
This is quite efficient requiring an average of
1.32 iterations per acceptance.
3.
Box-Muller
Let X, Y ~ N(0, 1), X, Y independent
Consider a transformation to polar coordinates:

To get the joint distribution of
and
need Jacobian of the transformation

Since ![]()
for ![]()
So
and
are independent. Furthermore
.
So proceed by generating
and
and then setting

resulting in two independent standard normal
random variables.
![]()
Consider the n-th smallest of n +
m – 1 random 0-1 numbers.


has a beta distribution with params n of m.
A problem with this approach is that finding
the n-th smallest of n + m – 1 random numbers is
expensive if n, m are large.