Random Variables 
Example: The Game of CrapsAdding a Random VariableUser Defined FunctionsPlotting DistributionsSimulating a Random Variable 

The game of Craps is a popular gambling game. In this game, the player rolls a pair of dice and sums the numbers showing. A sum of 7 or 11 wins for the player, and a sum of 2, 3, or 12 loses. Any other number is called the point. The player then rolls the dice again. If she rolls the point number, she wins. If she throws a 7, she loses. Any other number requires another roll. The game continues until the gambler rolls a 7 or her point number.

Simple probably analysis determines that the sum of two standard dice is a discrete random variable with integer values ranging from 2 through 12. The probability distribution of the sum is the triangular distribution with a mode of 7. To define this distribution for subsequent computation, select the Add_RV item from the OR_MS menu. The dialog box shown below opens. 
Sixteen named distributions are available with one user defined distribution. The option buttons at the left select discrete distributions, while the option buttons on the right select continuous distributions. The User distribution allows entry of a user specified discrete probability distribution. For the example we name the random variable Dice, identify it as an integer triangular distribution, specify its lower value, mode and upper value as 2, 7 and 12 respectively. The check boxes on the right of the dialog, list optional information that will be shown with the distribution.
One or more random variables must be defined with the Add_RV option before any of the other programs or functions may be used. The names for random variables must be unique and not previously defined for the workbook. The cell reference shown at the top of the dialog box is the upper left corner of the worksheet range where the random variable information will be stored. The default value of the cell is the reference to the cursor location when the dialog is called. When the "Show Titles" checkbox is clicked, the titles associated with the distribution parameters are shown. When not clicked only the parameters are shown without titles. The latter is useful when a series of random variables are defined each with the same set of parameters.
After identifying a distribution and defining appropriate parameters, the random variable information is placed on the worksheet with the rectangular construction as in the example. For each random variable defined in this manner, an Excel Name is assigned to that portion of the array that identifies the distribution type and parameters. For the example the four cells headed by "Triang_Int" are given the name "Dice". Again the name must obey Excel restrictions on naming regions of the worksheet. The random variable is referenced by this name. Any number of random variables may be included on the worksheet. Once defined, the distribution parameters may be changed by simply typing a new value. Distribution parameters may also be functions determined by other cells on the worksheet. The example also shows additional information regarding the random variable. These are obtained with user defined functions, to be described later. 


To create a User Distribution, place the cursor on the sheet where you want the distribution to appear. Choose Add RV from the OR_MS menu, enter the name and number of cells defining the distribution. The resulting display with 5 cells is shown below. Once the table is defined, the user enters the several possible values of the random variable and the associated values of the probability distribution as in the example. The distribution values should sum to 1, however, the functions will normalize the distribution if the total probability is not 1. 