Simulations using Excel

advertisement
Simulations using Excel
Simulations are useful ways of investigating situations involving
elements of chance. Using computers enables us to model real world
situations and replicate them many times, approaching a long run
probability for the situation.
Excel can be used to create simulations using only a few formula
commands, but there is potential for students (and teachers) to build
on those simple simulations to create more complex models.
Excel commands for simple programming:
=RANDBETWEEN(bottom, top)*
The RANDBETWEEN function syntax has the following arguments:


Bottom The smallest integer RANDBETWEEN will return.
Top The largest integer RANDBETWEEN will return.
Returns a random integer number between the numbers you specify. A new random integer
number is returned every time the worksheet is calculated.
Randbetween is easier to work with than the tradition random decimal. For instance, to simulate
the roll of one die, use =randbetween(1,6).
= IF(logical_test, [value_if_true], [value_if_false])
The IF function returns one value if a condition you specify evaluates to TRUE, and another value
if that condition evaluates to FALSE. For example, the formula =IF(A1>10,"Over 10","10 or
less") returns "Over 10" if A1 is greater than 10, and "10 or less" if A1 is less than or equal to 10.
The IF function syntax has the following arguments:
The logical_test is any value or expression that can be evaluated to TRUE or FALSE. If the first
option is true, then the value if true will go in the cell. If the logical test is false, the value if
false will go in the cell. For example, if a dice is rolled and the player scores a win if the roll is a 2:
die roll
win
Entering these commands (and filling down): =RANDBETWEEN(1,6) =IF(A2=2,1,0)
die roll
will give this result:
In the win column each cell will either record a 1 if the roll is a 2, or a 0 if any
other number.
With just these two commands and the ability to add using =sum( ) and to fill
down, students can do a simple simulation. Adding a few more commands
like =countif( ) gives a bit more flexibility. Using nested IF commands like
=if( , ,if( , ,if( , , ))) also adds more possibilities to the simulation.
The $ sign creates a fixed cell, column or row reference instead of a
corresponding one (eg $A$2, $A2, A$2).
win
6
3
4
3
6
3
2
6
1
6
*You might need to install this by going file/options/add-ins/Analysis ToolPak [plain or VBA].
0
0
0
0
0
0
1
0
0
0
Download