Java代写 | Math381 Assignment 5 Dice game

本次Java代写是完成一个骰子游戏并进行结果数据统计

Math381 Assignment 5 Dice game

In this assignment, we create a dice game and then play this game. Here is the rules:
The game begins with a score of zero.
Then you roll a fair, six-sided die with faces 1, 2, 3, 4, 5, 6, and you add the face value to your score.
Then you roll the dice again.
Notice that the face value of the first roll is always added to the score. Then on subsequent rolls, if the face
value that turns up divides the score, then divide the score by the face value.
Otherwise, add the face value to your score.
Continue rolling the dice until the score is 10 or more, then the game ends.
Since we start with a score of zero and end with a score of 10 or more, we model this game with a Markov
chain with eleven states: {s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11} = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}. Each state
indicates our current score of the game. Let state 10 to be the one absorbing state, so once we reach the
limit 10 (a score of 10) or beyond, the game ends, and our score does not change.
I write the matlab code in order to generate the transition matrix:
The output of this code gives us the transition matrix, the average rolls we will take, and the probability
that 10 or more rolls are needed. First, here is our transition matrix:
To calculate expected value, define matrix N = (I − Q)
−1 where I is the identity matrix and Q is the
non-negative matrix that arises from the transition probabilities between non-absorbing states. Summing
the first roll or matrix N = (I − Q)
−1 gives us the expected number or rolls until we reach the absorbing
state 10 (Notice that i means the i-th row):
E[X] = X
11
i=1
N
To calculate the probability that 10 or more rolls are needed, first, we want to find the probability that less
than 10 rolls are needed, which is P(X < 10). in this case,
P(X < 10) = X
11
i=1
M9
So we have the complete equation:
P(X ≥ 10) = 1 − P(X < 10) = 1 −
X
11
i=1
M9
The following is a graph showing the expected number of rolls and the probability that 10 or more rolls are
needed, and the expected value with different limit.


程序代写代做C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB


本网站支持淘宝 支付宝 微信支付  paypal等等交易。如果不放心可以用淘宝交易!

E-mail: [email protected]  微信:itcsdx


如果您使用手机请先保存二维码,微信识别。如果用电脑,直接掏出手机果断扫描。

blank

发表评论