Documente Academic
Documente Profesional
Documente Cultură
Course
Study Mode
Full Time
_____________________________________________________________________
UOW Moderator
Lecturer
: Mr Aaron Yeo
Weightage
: 30% of Subject
_____________________________________________________________________
Table of Contents
1 Introduction........................................................................................................ 3
2 Variation Over Time............................................................................................ 4
2.1 Introduction.................................................................................................. 4
2.2 OCBC Stock Price.......................................................................................... 4
2.2.1 Running mean smoothing on price.........................................................4
2.2.2 Running median smoothing on price......................................................5
2.3 OCBC Trading Volume...................................................................................8
2.4 Stock Price of OCBC versus DBS...................................................................9
2.5 Trading Volume of OCBC versus DBS..........................................................10
3 Dice Game Strategy Simulation........................................................................11
3.1 1st Strategy (Original)................................................................................. 11
3.2 2st Strategy................................................................................................. 11
3.3 3rd Strategy................................................................................................. 12
3.4 Conclusion.................................................................................................. 13
4 Monty Hall simulation....................................................................................... 14
4.1 Monty Hall simulation.................................................................................14
4.1.1 Introduction.......................................................................................... 14
4.1.2 Winning probability..............................................................................14
4.1.3 VBA program........................................................................................ 14
4.1.4 Results.................................................................................................. 15
4.2 Monty Hall simulation: Modification to 4 doors...........................................15
4.2.1 Introduction.......................................................................................... 15
4.2.2 Winning probability..............................................................................15
4.2.3 VBA program: 4 doors simulation.........................................................16
4.2.4 Results.................................................................................................. 16
4.3 Monty Hall simulation: Modification to 5 doors...........................................16
4.3.1 Introduction.......................................................................................... 16
4.3.2 Probability of winning...........................................................................16
4.3.3 VBA program: 5 doors simulation.........................................................17
4.3.4 Results.................................................................................................. 17
5 Appendix........................................................................................................... 18
Appendix A: VBA Program for Monty Hall simulation of 3 Doors.......................18
Appendix B: VBA Program for Monty Hall simulation of 4 Doors.......................19
Appendix C: VBA Program for Monty Hall simulation of 5 Doors.......................20
1 Introduction
This report consists of main 3 parts, analysing the trend and pattern of a stock
counter, simulation of dice game strategy, and simulation of the probability of
the Monty Hall problem.
In the first part, a simple statistical software tools was developed to analyse
stock prices and volume for Oversea-Chinese Banking Corporation over the
period of 5 years STI (Strait Times Index). We counter analysed the stocks with
The Development Bank of Singapore (DBS) to identify the trend and pattern of
the stocks and performed various smoothing techniques to achieve this result.
In the second part, a Visual Basic for Applications (VBA) program is done to find
the probability of the player winning/losing the game of dice. Every time he
guesses correctly, he wins, else he loses. There is the original version with an
unbiased outcome and 2 alternate versions with biased outcomes.
In the last part, a VBA program was used to simulate the Monty Hall problem.
The probability of the original Monty Hall problem was discussed and simulated,
and also further modified to 4 doors and 5 doors. The probability of the player
winning if the player chooses to change the door was worked out and discussed.
Price
4000
3000
2000
1000
0
Time
Price
4000
3500
3000
2500
2000
1500
1000
500
0
Time
Figure 2: Graph of 81 point running mean smoothing on OCBC price over time
Price
4000
3500
3000
2500
2000
1500
1000
500
0
Time
Figure 3: Graph of 41 point running mean smoothing on OCBC price over time
Price
1500
1000
500
0
Time
Figure 4: Graph of 31 point running mean smoothing on OCBC price over time
Different k values were used to see what differences it has on the graph. The k
values were used are 3, 31, 41 and 71. After compiling all the plotted graphs for
the different k values, the graph with 41 point running mean gave the smoothest
and accurate pattern. For the graph of 81 point, the graph was very smooth and
all the minor changes were also smoothened out along with the outliers. The
graph for the k value 31 and 3, a general pattern is hard to infer from the graph,
hence these two graphs were not used.
Price
4000
3500
3000
2500
2000
1500
1000
500
0
Time
Figure 5: Graph of 81 point running median smoothing on OCBC price over time
Price
4000
3500
3000
2500
2000
1500
1000
500
0
Time
Figure 6: Graph of 41 point running median smoothing on OCBC price over time
Price
4000
3500
3000
2500
2000
1500
1000
500
0
Time
Price
4000
3500
3000
2500
2000
1500
1000
500
0
Time
Volume
400000000
200000000
0
Time
different k-values was used to see what differences it has on the graph. The k
values that were used are 3, 31, 41 and 81.
The 81 point running mean had the smoother graph.
Volume
150000000
100000000
50000000
0
Time
Figure 10: Graph of 81 point running mean smoothing on OCBC volume over
time
As seen from Figure 7 above, from the end of the year 2012 to first quarter of
2013 there is a drastic increase in the volume which results in the peak point for
the whole period. From there the end of 2013 there is a sharp decrease. After this
point, increase in volume to the first quarter of 2014, which is accompanied by a
decrease till the mid of 2014. After the mid of 2014, there seems to be a general
increase in trend with a lots of fluctuations until the third quarter of 2014.
Price
DBS
OCBC
DBS
4000
3500
3000
2500
2000
1500
1000
500
0
Time
Figure 11: Graph of 41 point running median smoothing on price of OCBC vs DBS
The 41-point running median graphs regarding prices for both OCBC and DBS
from the year 2010 to the year 2015 were combined and analysed. There is an
overall increase in prices for both the banks from the 2010 till the end of 2014. In
2015, OCBC has a decrease in prices while for DBS the price remains constant.
There is a period in the graph where the prices for OCBC and DBS is more or less
the same from mid of 2013 to the first half of 2015.
DBS shows a more steady increase in the prices from 2010 to 2015, while OCBS
has many fluctuations. There is an overall increase in DBS while in OCBC the
value remains almost the same over the period of 5 years.
10
Volume
10000
5000
0
Time
DBS
OCBC
11
12
We notice that the probability of an even outcome is 27/36 while the probability
of an odd outcome is 9/36. Furthermore, guessing even or odd correctly is
considered a winning one round. If he wins one round, he will get back double
the chips. But if he guesses wrongly, he will not get the chips back.
If we simulate it, with a starting chips of 100 and it goes for 10 rounds, it will be
like this,
Round 1:
Players guess: odd
Players bet: 10 chips
Dice product: 6 x 2 = 12
(even)
Result: player lost
Remaining chips: 90
Round 4:
Players guess: even
Players bet: 12 chips
Dice product: 2 x 1 = 2
(even)
Result: player wins
Remaining chips: 136
Round 7:
Players guess: odd
Players bet: 18 chips
Dice product: 5 x 6 = 30
(even)
Result: player lost
Remaining chips: 150
Round 10 (final):
Players guess: odd
Players bet: 9 chips
Round 2:
Players guess: even
Players bet: 15 chips
Dice product: 5 x 4 = 20
(even)
Result: player wins
Remaining chips: 120
Round 5:
Players guess: even
Players bet: 6 chips
Dice product: 4 x 6 = 24
(even)
Result: player wins
Remaining chips: 148
Round 8:
Players guess: even
Players bet: 7 chips
Dice product: 4 x 5 = 20
(even)
Result: player wins
Remaining chips: 164
Round 3:
Players guess: even
Players bet: 8 chips
Dice product: 3 x 3 = 9
(even)
Result: player lost
Remaining chips: 112
Round 6:
Players guess: even
Players bet: 10 chips
Dice product: 6 x 6 = 36
(even)
Result: player wins
Remaining chips: 168
Round 9:
Players guess: even
Players bet: 10 chips
Dice product: 3 x 6 = 18
(even)
Result: player wins
Remaining chips: 184
13
Dice product: 2 x 5 = 10
(even)
Result: player loses
Remaining chips: 174
In this result, we notice that he wins 6/10 times and loses 4/10 times. With just
10 rounds, he was able to go from the initial 100 rounds to a final 174 chips. And
this is assuming the player never bets more than 20 chips. Therefore, it increases
the chances of winning for the player and a huge loss for the casino is every
gambler chooses to play this game.
3.4 Conclusion
The 2nd strategy will result in the probability of the player losing more and the 3 rd
strategy will result in the probability of the player winning more.
14
Car
33%
67%
Goat
67%
33%
15
to find out if it is always to the players advantage to change the door, and if it
agrees with the calculated probability of choosing a car by changing doors.
4.1.4 Results
The results of the several VBA simulation shows about 6606 wins in 10000
rounds to 6739 wins in 10000 rounds for each simulation, rounded up to around
66-67% chance of winning.
The calculated probability of 67% is within the range of the simulation results,
and as both simulation results and calculated probability shows that if the player
changes door, the probability of the player winning is high, about 66% to 67%.
Therefore, it is always to the players advantage to change the door.
Car
25%
75%
Goat
75%
25%
16
Assuming the players always change the door, the probability of picking a goat is
25% by picking the car the first time, and the probability of picking a car is 75%,
by picking the goat the first time. Therefore, the player will win as long as the
player initially chose a door with the goat.
Hence, the probability worked out shows that it is to the players advantage to
swap as the chance of picking a car is 75% if the player changes door, as
compared to the chance of picking a car with 25% if the player does not change
door.
4.2.4 Results
The results of the several VBA simulation shows about 7450 wins in 10000
rounds to 7599 wins in 10000 rounds for each simulation, rounded up to around
74-76% chance of winning.
The calculated probability of 75% is within the range of the simulation results,
and as both simulation results and calculated probability shows that if the player
changes door, the probability of the player winning is high, about 74% to 76%.
Therefore, it is always to the players advantage to change the door.
17
4.3.4 Results
The results of the several VBA simulation shows about 7951 wins in 10000
18
rounds to about 8069 wins in 10000 rounds for each simulation, rounded up to
around 80-81% chance of winning.
The calculated probability of 80% is within the range of the simulation results,
and as both simulation results and calculated probability shows that if the player
changes door, the probability of the player winning is high, about 80% to 81%.
Therefore, it is always to the players advantage to change the door.
19
5 Appendix
Appendix A: VBA Program for Monty Hall simulation of 3 Doors
20
21
22