Вы находитесь на странице: 1из 4

Simulation Techniques

Many real-life problems can be solved by employing simulation techniques.


A simulation technique uses a probability experiment to mimic a real-life situation.
Instead of studying the actual situation, which might be too costly, too dangerous, or too time-
consuming, scientists and researchers create a similar situation but one that is less expensive, less
dangerous, or less time-consuming. For example, N! uses space shuttle flight simulators so that its
astronauts can practice flying the shuttle. Most video games use the computer to simulate real-life
sports such as boxing, wrestling, baseball, and hoc"ey.
#omputers have played an important role in simulation techniques, since they can generate random
numbers, perform experiments, tally the outcomes, and compute the probabilities much faster than
human beings. $he basic simulation technique is called the Monte Carlo method. $his topic is
discussed next.
The Monte Carlo Method
$he Monte Carlo method is a simulation technique using random numbers. Monte #arlo
simulation techniques are used in business and industry to solve problems that are extremely difficult
or involve a large number of variables. $he steps for simulating real life experiments in the Monte
#arlo method are as follows%
1. &ist all possible outcomes of the experiment.
2. 'etermine the probability of each outcome.
3. !et up a correspondence between the outcomes of the experiment and the random numbers.
4. !elect random numbers from a table and conduct the experiment.
5. (epeat the experiment and tally the outcomes.
6. #ompute any statistics and state the conclusions.
)efore examples of the complete simulation technique are given, an illustration is needed for step *
+set up a correspondence between the outcomes of the experiment and the random numbers,. $ossing
a coin, for instance, can be simulated by using random numbers as follows% !ince there are only two
outcomes, heads and tails, and since each outcome has a probability of , the odd digits +-, *, ., /, and
0, can be used to represent a head, and the even digits +1, 2, 3, 4, and 5, can represent a tail. !uppose a
random number 54*- is selected. $his number represents four tosses of a single coin and the results $,
$, 6, 6. 7r this number could represent one toss of four coins with the same results. n experiment of
rolling a single die can also be simulated by using random numbers. In this case, the digits -, 2, *, 3,
., and 4 can represent the number of spots that appear on the face of the die. $he digits /, 5, 0, and 1
are ignored, since they cannot be rolled.
3
8hen two dice are rolled, two random digits are needed. For example, the number 24 represents a
2 on the first die and a 4 on the second die. $he random number */ represents a * on the first die, but
the / cannot be used, so another digit must be selected. s another example, a three-digit daily lotto
number can be simulated by using three-digit random numbers.
EXAMPL 1:
9sing random numbers, simulate the gender of children born.
Solution
$here are only two possibilities, female and male. !ince the probability of each outcome
is 1.., the odd digits can be used to represent male births and the even digits to represent
female births.
x=sample(0:9,1)
ielse(x!!2==0,"#","$")
or
sample(%("#","&"),1)
EXAMPL 2:
9sing random numbers, simulate the outcomes of a tennis game between )ill and Mi"e,
with the additional condition that )ill is twice as good as Mi"e.
Solution
!ince )ill is twice as good as Mi"e, he will win approximately two games for every
one Mi"e wins: hence, the probability that )ill wins will be , and the probability that
Mi"e wins will be . $he random digits - through 4 can be used to represent a game )ill
wins: the random digits /, 5, and 0 can be used to represent Mi"e;s wins. $he digit 1 is
disregarded. !uppose they play five games, and the random number 54*-3 is selected.
$his number means that )ill won games 2, *, 3, and . and Mi"e won the first game.
$he sequence is
' 6 3 1 4
M ) ) ) )
Using R :
sample(%("#ill","Mi(e"),5,),%(.66,.33))
EXAMPL 3:
die is rolled until a 4 appears. 9sing simulation, find the average number of rolls needed. $ry the
experiment 21 times.
Solution
Step 1 &ist all possible outcomes. $hey are -, 2, *, 3, ., 4.
Step 2 ssign the probabilities. <ach outcome has a probability of .
Step 3 !et up a correspondence between the random numbers and the outcome. 9se random numbers
- through 4. 7mit the numbers /, 5, 0, and 1.
Step 4 !elect a bloc" of random numbers, and count each digit - through 4 until the first 4 is obtained.
For example, the bloc" 5./2*4 means that it ta"es 3 rolls to get a 4.
5 . / 2 * 4
. 2 * 4
Step 5 (epeat the experiment -0 more times and tally the data as shown.
)rial *andom n+m,er -+m,er o rolls

- 5 . / 2 * 4 3
2 2 - 1 3 5 1 - . - - 1 - . * 4 --
* 2 * * 4 3
3 2 3 - * 1 3 5 * 4 /
. 3 2 - 4 3
4 * / . 2 1 * 0 5 / . 5 - 5 * / - 4 0
/ / / 0 2 - 1 4 *
5 0 0 . 4 2
0 0 4 -
-1 5 0 . / 0 - 3 * 3 2 4 /
-- 5 . 3 / . * 4 .
-2 2 5 0 - 5 4 *
-* 4 -
-3 1 0 3 2 0 0 * 0 4 3
-. - 1 * 4 *
-4 1 / - - 0 0 / * * 4 .
-/ . - 1 5 . - 2 / 4 4
-5 1 2 * 4 *
-0 1 - 1 - - . 3 1 0 2 * * * 4 -1
21 . 2 - 4 3
$otal 04
Step 6 #ompute the results and draw a conclusion. In this case, one must find the average.
= = =

21
04
==
n
X
X 3.5
6ence, the average is about . rolls.
Note: $he theoretical average obtained from the expected value formula is 4. If this experiment is
done many times, say -111 times, the results should be closer to the theoretical results.
Using R :
.=0
or (/ in 1:20)0
x=sample(6,1)1i=1
%at("x=",x, "2n")
3hile(x4=6)0
i=i51
x=sample(6,1)
%at("x=",x,"2n")
6
.7/8=i
%at("sample",/,"9-o. o triles=",i,"2n")
6
mean(.)
EXAMPL 3:
box contains five >- bills, three >. bills, and two >-1 bills. person
selects a bill at
random. 8hat is the expected value of the bill? @erform the experiment 2.
times.
Solution
Step 1 &ist all possible outcomes. $hey are >-, >., and >-1.
Step 2 ssign the probabilities to each outcome
Step 3 !et up a correspondence between the random numbers and the outcomes. 9se random numbers
- through . to represent a >- bill being selected, 4 through 5 to represent a >. bill being selected, and
and 1 to represent a >-1 bill being selected.
Steps 4 and 5 !elect 2. random numbers and tally the results.
-+m,er *es+lts (:)
3 . 5 2 0 -, -, ., -, -1
2 . 4 3 4 -, -, ., -, .
0 - 5 1 * -1, -, ., -1, -
5 3 1 4 1 ., -, -1, ., -1
0 4 0 3 * -1, ., -1, -, -
Step 6 #ompute the average%
E+X, =AX . P+X,B= +1..,+>-, + +1.*,+>., + +1.2,+>-1, = >3.11
Using R :
x=sample(0:9,25,))
x
.=ielse(x;=4,1,ielse(x<=,10,5))
mean(.)
expe%ted.>al+e=.5?15.3?55.2?10
expe%ted.>al+e
HOMEWORK:
person selects a "ey at random from four "eys to open a loc". 7nly one "ey fits. If the first "ey
does not fit, she tries other "eys until one fits. Find the average of the number of "eys a person will
have to try to open the loc". $ry the experiment 2. times.
Solution
ssume that each "ey is numbered from - through 3 and that "ey 2 fits the loc". Naturally, the person
doesn;t "now this, so she selects the "eys at random. For the simulation, select a sequence of random
digits, using only - through 3, until the digit 2 is reached. $he trials are shown here.
)rial *andom di@it ((e.) -+m,er )rial *andom di@it ((e.) -+m,er
- 2 - -3 2 -
2 2 - -. 3 2 2
* - 2 2 -4 - * 2 *
3 - 3 * 2 3 -/ - 2 2
. * 2 2 -5 2 -
4 * - 3 2 3 -0 * 3 2 *
/ 3 2 2 21 2 -
5 3 *2 * 2- 2 -
0 3 2 2 22 2 -
-1 2 - 2* 3 2 2
-- 3 2 2 23 3 * - 2 3
-2 * - 2 * 2. * - 2 *
-* * - 2 *
$otal .3
Next, find the average%
-4 . 2
2.
.3
==
= = =

n
X
X
$he theoretical average is 2.2. gain, only 2. repetitions were used: more
repetitions should give a result closer to the theoretical average.
- using ( to simulate the experiment.

Вам также может понравиться