Generating the Bernoulli random variable is very easy and is better than actually tossing a coin many times. This video illustrates Exercise 2.1 from my book: how to use Excel RAND() and IF functions to simulate the coin in Excel

Simulation steps

RAND() (with empty parentheses) is the Excel function to generate a uniformly distributed random variable on the interval . If you enter the command =RAND() in two different cells, the generated variables will be independent. The generated values will be recalculated each time you change the spreadsheet, unless the Recalculate option is off.

The IF function has three arguments. The first argument is a condition. If the condition is satisfied, the IF function supplies the second argument. If not, the third argument is produced. For example, the command =IF(RAND()>0.3,1,0) simulates an unfair coin: the value 1 is taken 70% of the time.

The RAND() command is also used to generate normally distributed variables. A similar construction allows one to simulate any random variable with an invertible cumulative distribution function, see Exercise 7.6 in my book.

## Leave a Reply

You must be logged in to post a comment.