# Chapter 3Applied Chapter: Generating Random Variables

In this chapter we talk about methods used for simulating random variables. In today's world, where computers are part of any scientific activity, it is very important to know how to simulate a random experiment to find out what expectations one may have about the results of the phenomenon. We shall see later that the Central Limit Theorem (Theorem 7.43) and the Monte Carlo method allow us to draw conclusions about the expectations even if the distributions involved are very complex.

We assume as given a Uniform(0,1) random number generator. Any software can produce such a uniform random variable and the typical name for a uniform random number is RAND. For more current references and a very efficient way to generate exponential and normal random variables without going to uniform, we refer the reader to 2006. The ziggurat method developed by 2000 remains one of the most efficient ways to produce normals and it is used by MATLAB®. The Mersene twister is an efficient way to create uniform random numbers. In this chapter, we will present pseudo-code and code written in R for some of these random variable generation methods. R is an open source program which, in my opinion, is one of the strongest statistical programs ever developed.

## 3.1 Generating One-Dimensional Random Variables by Inverting the cdf

Let *X* be a one-dimensional random variable defined on any probability space with distribution function . All the distribution ...