Академический Документы
Профессиональный Документы
Культура Документы
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.