# Python代写 | Simulation Modelling (37262) – Workshop 3 Labwork

University of Technology Sydney School of Mathematical and Physical Sciences

Simulation Modelling (37262) – Workshop 3 Labwork

Please ensure that all work is clearly communicated and any answers clearly labelled in the simulation file(s). If you need to write anything additional to the simulation file, you may do so (either on paper to hand in, or as an electronic file.) Explanations should be clear and concise – usually no more than one paragraph per question.

Please submit your simulation code/worksheet plus any additional electronic files by the conclusion of the lab class through Canvas, clearly stating your name and student number. Simulations may be done in any suitable mathematical language or package. Please indicate which has been used when submitting work.

1.
A gambler bets repeatedly on a standard (European-style) roulette

wheel. Each time he/she bets \$1 and gains an additional \$1 with probability 18 and loses his/her stake with probability 19 . The gambler

begins with \$15 and bets repeatedly until he/she first reaches \$20 (wins) or reaches \$0 (loses.)
Simulate 100 full runs of the gambler’s games until he/she reaches either absorbing boundary. From these simulations, estimate:

1. i)  The probability that the gambler reaches \$20 and not \$0;
2. ii)  The probability that the gambler places more than 50 bets before

reaching either boundary;

3. iii)  The expected number of bets placed before reaching either

boundary;

4. iv)  The expected number of times that the gambler has exactly \$17

during each full game.

Note: 100 full runs of the game requires simulation of 100 times that the player’s money begins at \$15 and ends at either \$0 or \$20, not just 100 bets.

37 37

2. A game is played whereby a player rolls a regular fair six-sided die. If the die shows an even number, the player’s score is zero. If the die shows an odd number, the player scores the number of points shown, i.e. if the die shows a 5, the player scores 5 points.

Simulate 1000 realisations of this game.

i) From your simulations, estimate the expected number of points scored in a single game.

The player is now given a call option, allowing (but not obliging) the player to swap his/her prize for a prize of 2 points. This call can be made after the die roll is observed and the player will always act to maximise his/her score.

ii) From your simulations, estimate the fair price for this call option.

3. Consider an undirected random graph on the set of four nodes {A, B, C, D} such that each of the  4  = 6 potential edges exists

with probability 0.3, independently of the presence/absence of any other edges.
A graph is connected if any node can be reached along an edge or combination of edges starting from any other. For example, if edges AC, AD and BD were present, but potential edges AB, BC and CD were absent, the graph would still be connected, since any node can still be reached from any other.

Simulate 1000 such random graphs.
i) From your simulations, estimate the probability that such a

random graph is connected

The shortest path length between two nodes is defined as smallest number of edges which can be used to link the two nodes. For example, if edge AB exists, then the shortest path length between A and B is 1. If AB does not exist, but edges AC and BC exist, then the shortest path length is 2. The shortest path length between two nodes on a disconnected graph may be infinite.

ii) From your simulations, estimate the expected shortest path length between two nodes, excluding cases where this value is infinite i.e. excluding disconnected graphs.

2  E-mail: itcsdx@outlook.com  微信:itcsdx 