Probability of the sum of cards?










1














The problem is basically as follows



There are four cards with points [1,2,3,4], every time I draw one card randomly and then put it back to the deck. As I keep drawing I record the sum of the points on the cards, I stop drawing if the sum is greater than or equal to five.



If the final points is equal to five, I win, otherwise I lose. What's the probability of me winning?




My attempt to solve this problem is, let $p_n$ be the probability of the sum EVER equal to $n$ after drawing enough number of times, specifically
$$p_1=frac14 text (draw 1 once)$$
$$p_2=frac14 + frac14p_1 text (draw 2 once + draw 1 twice) $$
$$p_3=frac14 + frac14p_1 + frac14p_2 $$
$$p_4=frac14 + frac14p_1 + frac14p_2 + frac14p_3 $$
then $p_5=frac14p_1 + frac14p_2 + frac14p_3 + frac14p_4 = 369/1024$ should be the probability of winning at five.



However I was told that the answer should be around 0.33 so I'm confused, is my answer correct?




Update
It turns out 0.33 (1/3) is the answer for sampling without replacement.










share|cite|improve this question























  • I think 0.33 is also too high. Try a tree diagram. That helped me.
    – dankernler
    Nov 12 at 4:27






  • 1




    Let $p_n$ be the probability of win at the n-th draw. $p_2=frac 14, p_3=frac 664, p_4 = frac 164, p_5 = frac 11024$, $p(win)=sum p_n = frac 3691024$. Proved your result from another aspect.
    – user158565
    Nov 12 at 4:50







  • 1




    Your calculation appears to be correct.
    – Glen_b
    Nov 12 at 5:29










  • @a_statistician thanks for the answer!
    – dontloo
    Nov 12 at 5:33















1














The problem is basically as follows



There are four cards with points [1,2,3,4], every time I draw one card randomly and then put it back to the deck. As I keep drawing I record the sum of the points on the cards, I stop drawing if the sum is greater than or equal to five.



If the final points is equal to five, I win, otherwise I lose. What's the probability of me winning?




My attempt to solve this problem is, let $p_n$ be the probability of the sum EVER equal to $n$ after drawing enough number of times, specifically
$$p_1=frac14 text (draw 1 once)$$
$$p_2=frac14 + frac14p_1 text (draw 2 once + draw 1 twice) $$
$$p_3=frac14 + frac14p_1 + frac14p_2 $$
$$p_4=frac14 + frac14p_1 + frac14p_2 + frac14p_3 $$
then $p_5=frac14p_1 + frac14p_2 + frac14p_3 + frac14p_4 = 369/1024$ should be the probability of winning at five.



However I was told that the answer should be around 0.33 so I'm confused, is my answer correct?




Update
It turns out 0.33 (1/3) is the answer for sampling without replacement.










share|cite|improve this question























  • I think 0.33 is also too high. Try a tree diagram. That helped me.
    – dankernler
    Nov 12 at 4:27






  • 1




    Let $p_n$ be the probability of win at the n-th draw. $p_2=frac 14, p_3=frac 664, p_4 = frac 164, p_5 = frac 11024$, $p(win)=sum p_n = frac 3691024$. Proved your result from another aspect.
    – user158565
    Nov 12 at 4:50







  • 1




    Your calculation appears to be correct.
    – Glen_b
    Nov 12 at 5:29










  • @a_statistician thanks for the answer!
    – dontloo
    Nov 12 at 5:33













1












1








1







The problem is basically as follows



There are four cards with points [1,2,3,4], every time I draw one card randomly and then put it back to the deck. As I keep drawing I record the sum of the points on the cards, I stop drawing if the sum is greater than or equal to five.



If the final points is equal to five, I win, otherwise I lose. What's the probability of me winning?




My attempt to solve this problem is, let $p_n$ be the probability of the sum EVER equal to $n$ after drawing enough number of times, specifically
$$p_1=frac14 text (draw 1 once)$$
$$p_2=frac14 + frac14p_1 text (draw 2 once + draw 1 twice) $$
$$p_3=frac14 + frac14p_1 + frac14p_2 $$
$$p_4=frac14 + frac14p_1 + frac14p_2 + frac14p_3 $$
then $p_5=frac14p_1 + frac14p_2 + frac14p_3 + frac14p_4 = 369/1024$ should be the probability of winning at five.



However I was told that the answer should be around 0.33 so I'm confused, is my answer correct?




Update
It turns out 0.33 (1/3) is the answer for sampling without replacement.










share|cite|improve this question















The problem is basically as follows



There are four cards with points [1,2,3,4], every time I draw one card randomly and then put it back to the deck. As I keep drawing I record the sum of the points on the cards, I stop drawing if the sum is greater than or equal to five.



If the final points is equal to five, I win, otherwise I lose. What's the probability of me winning?




My attempt to solve this problem is, let $p_n$ be the probability of the sum EVER equal to $n$ after drawing enough number of times, specifically
$$p_1=frac14 text (draw 1 once)$$
$$p_2=frac14 + frac14p_1 text (draw 2 once + draw 1 twice) $$
$$p_3=frac14 + frac14p_1 + frac14p_2 $$
$$p_4=frac14 + frac14p_1 + frac14p_2 + frac14p_3 $$
then $p_5=frac14p_1 + frac14p_2 + frac14p_3 + frac14p_4 = 369/1024$ should be the probability of winning at five.



However I was told that the answer should be around 0.33 so I'm confused, is my answer correct?




Update
It turns out 0.33 (1/3) is the answer for sampling without replacement.







probability self-study






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Nov 12 at 8:07

























asked Nov 12 at 4:12









dontloo

6,97132562




6,97132562











  • I think 0.33 is also too high. Try a tree diagram. That helped me.
    – dankernler
    Nov 12 at 4:27






  • 1




    Let $p_n$ be the probability of win at the n-th draw. $p_2=frac 14, p_3=frac 664, p_4 = frac 164, p_5 = frac 11024$, $p(win)=sum p_n = frac 3691024$. Proved your result from another aspect.
    – user158565
    Nov 12 at 4:50







  • 1




    Your calculation appears to be correct.
    – Glen_b
    Nov 12 at 5:29










  • @a_statistician thanks for the answer!
    – dontloo
    Nov 12 at 5:33
















  • I think 0.33 is also too high. Try a tree diagram. That helped me.
    – dankernler
    Nov 12 at 4:27






  • 1




    Let $p_n$ be the probability of win at the n-th draw. $p_2=frac 14, p_3=frac 664, p_4 = frac 164, p_5 = frac 11024$, $p(win)=sum p_n = frac 3691024$. Proved your result from another aspect.
    – user158565
    Nov 12 at 4:50







  • 1




    Your calculation appears to be correct.
    – Glen_b
    Nov 12 at 5:29










  • @a_statistician thanks for the answer!
    – dontloo
    Nov 12 at 5:33















I think 0.33 is also too high. Try a tree diagram. That helped me.
– dankernler
Nov 12 at 4:27




I think 0.33 is also too high. Try a tree diagram. That helped me.
– dankernler
Nov 12 at 4:27




1




1




Let $p_n$ be the probability of win at the n-th draw. $p_2=frac 14, p_3=frac 664, p_4 = frac 164, p_5 = frac 11024$, $p(win)=sum p_n = frac 3691024$. Proved your result from another aspect.
– user158565
Nov 12 at 4:50





Let $p_n$ be the probability of win at the n-th draw. $p_2=frac 14, p_3=frac 664, p_4 = frac 164, p_5 = frac 11024$, $p(win)=sum p_n = frac 3691024$. Proved your result from another aspect.
– user158565
Nov 12 at 4:50





1




1




Your calculation appears to be correct.
– Glen_b
Nov 12 at 5:29




Your calculation appears to be correct.
– Glen_b
Nov 12 at 5:29












@a_statistician thanks for the answer!
– dontloo
Nov 12 at 5:33




@a_statistician thanks for the answer!
– dontloo
Nov 12 at 5:33










2 Answers
2






active

oldest

votes


















3














Whenever there are conflicting answers from combinatorial methods, I
like to simulate the result to see what happens.



My method of simulation (in R) is to sample five cards with replacement from among 1, 2, 3, 4. Then to take cumulative sums of the results to see if the total 5 is
present at any step. If so, that's a win. (Any cards drawn after a total of 5
are ignored.)



After a million iterations the vector w has a million
TRUEs and FALSEs. The mean of this logical vector is the proportion
of its TRUEs. With a million iterations this proportion should approximate
the probability of winning to at least two or three places.



It seems that
simulation results match $369/1024 = 0.3603516,$ the answer proposed in your
Question and computed in the Comment
of @a_statistician.



set.seed(1112); m = 10^6; deck = 1:4
w = replicate( m, 5 %in% cumsum(sample(deck,5, rep=T)) )
mean(w); 369/1024; 15/49
[1] 0.360286 # aprx P(Win) = 0.3604
[1] 0.3603516 # exact P(Win) = 369/1024
[1] 0.3061224 # 15/49





share|cite|improve this answer




















  • Thanks for the verification :)
    – dontloo
    Nov 12 at 7:56


















0














I think another way to approach this problem is to model the game as a Markov chain with the following transition probability matrix, $M$:



$$
beginmatrix
& textFrom state \
textTo state &
beginarrayccccccc
& 0 & 1 & 2 & 3 & 4 & textwin & textlose \
hline
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \
1 & 1/4 & 0 & 0 & 0 & 0 & 0 & 0 \
2 & 1/4 & 1/4 & 0 & 0 & 0 & 0 & 0 \
3 & 1/4 & 1/4 & 1/4 & 0 & 0 & 0 & 0 \
4 & 1/4 & 1/4 & 1/4 & 1/4 & 0 & 0 & 0 \
textwin (5) & 0 & 1/4 & 1/4 & 1/4 & 1/4 & 1 & 0 \
textlose (5+) & 0 & 0 & 1/4 & 2/4 & 3/4 & 0 & 1
endarray
endmatrix
$$



Note that this is a reducible Markov chain: once we reach the win or lose state, we will be stuck there forever.



Our starting state is:
$$
v = beginbmatrix
1 & 0 & 0 & 0 & 0 & 0 & 0
endbmatrix^top
$$



Since we know that the game will end after five draws at most, we can calculate the probability distribution over the states after five draws by left multiplying $M$ with the initial state vector $v$ five times:
$$
M times M times M times M times M times v
$$



Implementation in R:



library(expm)

M <- matrix(nrow = 7,
c( 0, 0, 0, 0, 0, 0, 0,
.25, 0, 0, 0, 0, 0, 0,
.25, .25, 0, 0, 0, 0, 0,
.25, .25, .25, 0, 0, 0, 0,
.25, .25, .25, .25, 0, 0, 0,
0, .25, .25, .25, .25, 1, 0,
0, 0, .25, .5, .75, 0, 1),
byrow = T,
dimnames = list(c("0", "1", "2", "3", "4", "win", "lose"),
c("0", "1", "2", "3", "4", "win", "lose")))

M %^% 5 %*% c(1, 0, 0, 0, 0, 0, 0)


Output:



 [,1]
0 0.0000000
1 0.0000000
2 0.0000000
3 0.0000000
4 0.0000000
win 0.3603516
lose 0.6396484


The probability for the win state is consistent with $frac3691024$.




P.S. I do wonder though if there is a way to derive the distributions over the final states analytically without carrying out the matrix multiplications.






share|cite|improve this answer






















    Your Answer





    StackExchange.ifUsing("editor", function ()
    return StackExchange.using("mathjaxEditing", function ()
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    );
    );
    , "mathjax-editing");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "65"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstats.stackexchange.com%2fquestions%2f376522%2fprobability-of-the-sum-of-cards%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    Whenever there are conflicting answers from combinatorial methods, I
    like to simulate the result to see what happens.



    My method of simulation (in R) is to sample five cards with replacement from among 1, 2, 3, 4. Then to take cumulative sums of the results to see if the total 5 is
    present at any step. If so, that's a win. (Any cards drawn after a total of 5
    are ignored.)



    After a million iterations the vector w has a million
    TRUEs and FALSEs. The mean of this logical vector is the proportion
    of its TRUEs. With a million iterations this proportion should approximate
    the probability of winning to at least two or three places.



    It seems that
    simulation results match $369/1024 = 0.3603516,$ the answer proposed in your
    Question and computed in the Comment
    of @a_statistician.



    set.seed(1112); m = 10^6; deck = 1:4
    w = replicate( m, 5 %in% cumsum(sample(deck,5, rep=T)) )
    mean(w); 369/1024; 15/49
    [1] 0.360286 # aprx P(Win) = 0.3604
    [1] 0.3603516 # exact P(Win) = 369/1024
    [1] 0.3061224 # 15/49





    share|cite|improve this answer




















    • Thanks for the verification :)
      – dontloo
      Nov 12 at 7:56















    3














    Whenever there are conflicting answers from combinatorial methods, I
    like to simulate the result to see what happens.



    My method of simulation (in R) is to sample five cards with replacement from among 1, 2, 3, 4. Then to take cumulative sums of the results to see if the total 5 is
    present at any step. If so, that's a win. (Any cards drawn after a total of 5
    are ignored.)



    After a million iterations the vector w has a million
    TRUEs and FALSEs. The mean of this logical vector is the proportion
    of its TRUEs. With a million iterations this proportion should approximate
    the probability of winning to at least two or three places.



    It seems that
    simulation results match $369/1024 = 0.3603516,$ the answer proposed in your
    Question and computed in the Comment
    of @a_statistician.



    set.seed(1112); m = 10^6; deck = 1:4
    w = replicate( m, 5 %in% cumsum(sample(deck,5, rep=T)) )
    mean(w); 369/1024; 15/49
    [1] 0.360286 # aprx P(Win) = 0.3604
    [1] 0.3603516 # exact P(Win) = 369/1024
    [1] 0.3061224 # 15/49





    share|cite|improve this answer




















    • Thanks for the verification :)
      – dontloo
      Nov 12 at 7:56













    3












    3








    3






    Whenever there are conflicting answers from combinatorial methods, I
    like to simulate the result to see what happens.



    My method of simulation (in R) is to sample five cards with replacement from among 1, 2, 3, 4. Then to take cumulative sums of the results to see if the total 5 is
    present at any step. If so, that's a win. (Any cards drawn after a total of 5
    are ignored.)



    After a million iterations the vector w has a million
    TRUEs and FALSEs. The mean of this logical vector is the proportion
    of its TRUEs. With a million iterations this proportion should approximate
    the probability of winning to at least two or three places.



    It seems that
    simulation results match $369/1024 = 0.3603516,$ the answer proposed in your
    Question and computed in the Comment
    of @a_statistician.



    set.seed(1112); m = 10^6; deck = 1:4
    w = replicate( m, 5 %in% cumsum(sample(deck,5, rep=T)) )
    mean(w); 369/1024; 15/49
    [1] 0.360286 # aprx P(Win) = 0.3604
    [1] 0.3603516 # exact P(Win) = 369/1024
    [1] 0.3061224 # 15/49





    share|cite|improve this answer












    Whenever there are conflicting answers from combinatorial methods, I
    like to simulate the result to see what happens.



    My method of simulation (in R) is to sample five cards with replacement from among 1, 2, 3, 4. Then to take cumulative sums of the results to see if the total 5 is
    present at any step. If so, that's a win. (Any cards drawn after a total of 5
    are ignored.)



    After a million iterations the vector w has a million
    TRUEs and FALSEs. The mean of this logical vector is the proportion
    of its TRUEs. With a million iterations this proportion should approximate
    the probability of winning to at least two or three places.



    It seems that
    simulation results match $369/1024 = 0.3603516,$ the answer proposed in your
    Question and computed in the Comment
    of @a_statistician.



    set.seed(1112); m = 10^6; deck = 1:4
    w = replicate( m, 5 %in% cumsum(sample(deck,5, rep=T)) )
    mean(w); 369/1024; 15/49
    [1] 0.360286 # aprx P(Win) = 0.3604
    [1] 0.3603516 # exact P(Win) = 369/1024
    [1] 0.3061224 # 15/49






    share|cite|improve this answer












    share|cite|improve this answer



    share|cite|improve this answer










    answered Nov 12 at 7:50









    BruceET

    5,0331519




    5,0331519











    • Thanks for the verification :)
      – dontloo
      Nov 12 at 7:56
















    • Thanks for the verification :)
      – dontloo
      Nov 12 at 7:56















    Thanks for the verification :)
    – dontloo
    Nov 12 at 7:56




    Thanks for the verification :)
    – dontloo
    Nov 12 at 7:56













    0














    I think another way to approach this problem is to model the game as a Markov chain with the following transition probability matrix, $M$:



    $$
    beginmatrix
    & textFrom state \
    textTo state &
    beginarrayccccccc
    & 0 & 1 & 2 & 3 & 4 & textwin & textlose \
    hline
    0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \
    1 & 1/4 & 0 & 0 & 0 & 0 & 0 & 0 \
    2 & 1/4 & 1/4 & 0 & 0 & 0 & 0 & 0 \
    3 & 1/4 & 1/4 & 1/4 & 0 & 0 & 0 & 0 \
    4 & 1/4 & 1/4 & 1/4 & 1/4 & 0 & 0 & 0 \
    textwin (5) & 0 & 1/4 & 1/4 & 1/4 & 1/4 & 1 & 0 \
    textlose (5+) & 0 & 0 & 1/4 & 2/4 & 3/4 & 0 & 1
    endarray
    endmatrix
    $$



    Note that this is a reducible Markov chain: once we reach the win or lose state, we will be stuck there forever.



    Our starting state is:
    $$
    v = beginbmatrix
    1 & 0 & 0 & 0 & 0 & 0 & 0
    endbmatrix^top
    $$



    Since we know that the game will end after five draws at most, we can calculate the probability distribution over the states after five draws by left multiplying $M$ with the initial state vector $v$ five times:
    $$
    M times M times M times M times M times v
    $$



    Implementation in R:



    library(expm)

    M <- matrix(nrow = 7,
    c( 0, 0, 0, 0, 0, 0, 0,
    .25, 0, 0, 0, 0, 0, 0,
    .25, .25, 0, 0, 0, 0, 0,
    .25, .25, .25, 0, 0, 0, 0,
    .25, .25, .25, .25, 0, 0, 0,
    0, .25, .25, .25, .25, 1, 0,
    0, 0, .25, .5, .75, 0, 1),
    byrow = T,
    dimnames = list(c("0", "1", "2", "3", "4", "win", "lose"),
    c("0", "1", "2", "3", "4", "win", "lose")))

    M %^% 5 %*% c(1, 0, 0, 0, 0, 0, 0)


    Output:



     [,1]
    0 0.0000000
    1 0.0000000
    2 0.0000000
    3 0.0000000
    4 0.0000000
    win 0.3603516
    lose 0.6396484


    The probability for the win state is consistent with $frac3691024$.




    P.S. I do wonder though if there is a way to derive the distributions over the final states analytically without carrying out the matrix multiplications.






    share|cite|improve this answer



























      0














      I think another way to approach this problem is to model the game as a Markov chain with the following transition probability matrix, $M$:



      $$
      beginmatrix
      & textFrom state \
      textTo state &
      beginarrayccccccc
      & 0 & 1 & 2 & 3 & 4 & textwin & textlose \
      hline
      0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \
      1 & 1/4 & 0 & 0 & 0 & 0 & 0 & 0 \
      2 & 1/4 & 1/4 & 0 & 0 & 0 & 0 & 0 \
      3 & 1/4 & 1/4 & 1/4 & 0 & 0 & 0 & 0 \
      4 & 1/4 & 1/4 & 1/4 & 1/4 & 0 & 0 & 0 \
      textwin (5) & 0 & 1/4 & 1/4 & 1/4 & 1/4 & 1 & 0 \
      textlose (5+) & 0 & 0 & 1/4 & 2/4 & 3/4 & 0 & 1
      endarray
      endmatrix
      $$



      Note that this is a reducible Markov chain: once we reach the win or lose state, we will be stuck there forever.



      Our starting state is:
      $$
      v = beginbmatrix
      1 & 0 & 0 & 0 & 0 & 0 & 0
      endbmatrix^top
      $$



      Since we know that the game will end after five draws at most, we can calculate the probability distribution over the states after five draws by left multiplying $M$ with the initial state vector $v$ five times:
      $$
      M times M times M times M times M times v
      $$



      Implementation in R:



      library(expm)

      M <- matrix(nrow = 7,
      c( 0, 0, 0, 0, 0, 0, 0,
      .25, 0, 0, 0, 0, 0, 0,
      .25, .25, 0, 0, 0, 0, 0,
      .25, .25, .25, 0, 0, 0, 0,
      .25, .25, .25, .25, 0, 0, 0,
      0, .25, .25, .25, .25, 1, 0,
      0, 0, .25, .5, .75, 0, 1),
      byrow = T,
      dimnames = list(c("0", "1", "2", "3", "4", "win", "lose"),
      c("0", "1", "2", "3", "4", "win", "lose")))

      M %^% 5 %*% c(1, 0, 0, 0, 0, 0, 0)


      Output:



       [,1]
      0 0.0000000
      1 0.0000000
      2 0.0000000
      3 0.0000000
      4 0.0000000
      win 0.3603516
      lose 0.6396484


      The probability for the win state is consistent with $frac3691024$.




      P.S. I do wonder though if there is a way to derive the distributions over the final states analytically without carrying out the matrix multiplications.






      share|cite|improve this answer

























        0












        0








        0






        I think another way to approach this problem is to model the game as a Markov chain with the following transition probability matrix, $M$:



        $$
        beginmatrix
        & textFrom state \
        textTo state &
        beginarrayccccccc
        & 0 & 1 & 2 & 3 & 4 & textwin & textlose \
        hline
        0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \
        1 & 1/4 & 0 & 0 & 0 & 0 & 0 & 0 \
        2 & 1/4 & 1/4 & 0 & 0 & 0 & 0 & 0 \
        3 & 1/4 & 1/4 & 1/4 & 0 & 0 & 0 & 0 \
        4 & 1/4 & 1/4 & 1/4 & 1/4 & 0 & 0 & 0 \
        textwin (5) & 0 & 1/4 & 1/4 & 1/4 & 1/4 & 1 & 0 \
        textlose (5+) & 0 & 0 & 1/4 & 2/4 & 3/4 & 0 & 1
        endarray
        endmatrix
        $$



        Note that this is a reducible Markov chain: once we reach the win or lose state, we will be stuck there forever.



        Our starting state is:
        $$
        v = beginbmatrix
        1 & 0 & 0 & 0 & 0 & 0 & 0
        endbmatrix^top
        $$



        Since we know that the game will end after five draws at most, we can calculate the probability distribution over the states after five draws by left multiplying $M$ with the initial state vector $v$ five times:
        $$
        M times M times M times M times M times v
        $$



        Implementation in R:



        library(expm)

        M <- matrix(nrow = 7,
        c( 0, 0, 0, 0, 0, 0, 0,
        .25, 0, 0, 0, 0, 0, 0,
        .25, .25, 0, 0, 0, 0, 0,
        .25, .25, .25, 0, 0, 0, 0,
        .25, .25, .25, .25, 0, 0, 0,
        0, .25, .25, .25, .25, 1, 0,
        0, 0, .25, .5, .75, 0, 1),
        byrow = T,
        dimnames = list(c("0", "1", "2", "3", "4", "win", "lose"),
        c("0", "1", "2", "3", "4", "win", "lose")))

        M %^% 5 %*% c(1, 0, 0, 0, 0, 0, 0)


        Output:



         [,1]
        0 0.0000000
        1 0.0000000
        2 0.0000000
        3 0.0000000
        4 0.0000000
        win 0.3603516
        lose 0.6396484


        The probability for the win state is consistent with $frac3691024$.




        P.S. I do wonder though if there is a way to derive the distributions over the final states analytically without carrying out the matrix multiplications.






        share|cite|improve this answer














        I think another way to approach this problem is to model the game as a Markov chain with the following transition probability matrix, $M$:



        $$
        beginmatrix
        & textFrom state \
        textTo state &
        beginarrayccccccc
        & 0 & 1 & 2 & 3 & 4 & textwin & textlose \
        hline
        0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \
        1 & 1/4 & 0 & 0 & 0 & 0 & 0 & 0 \
        2 & 1/4 & 1/4 & 0 & 0 & 0 & 0 & 0 \
        3 & 1/4 & 1/4 & 1/4 & 0 & 0 & 0 & 0 \
        4 & 1/4 & 1/4 & 1/4 & 1/4 & 0 & 0 & 0 \
        textwin (5) & 0 & 1/4 & 1/4 & 1/4 & 1/4 & 1 & 0 \
        textlose (5+) & 0 & 0 & 1/4 & 2/4 & 3/4 & 0 & 1
        endarray
        endmatrix
        $$



        Note that this is a reducible Markov chain: once we reach the win or lose state, we will be stuck there forever.



        Our starting state is:
        $$
        v = beginbmatrix
        1 & 0 & 0 & 0 & 0 & 0 & 0
        endbmatrix^top
        $$



        Since we know that the game will end after five draws at most, we can calculate the probability distribution over the states after five draws by left multiplying $M$ with the initial state vector $v$ five times:
        $$
        M times M times M times M times M times v
        $$



        Implementation in R:



        library(expm)

        M <- matrix(nrow = 7,
        c( 0, 0, 0, 0, 0, 0, 0,
        .25, 0, 0, 0, 0, 0, 0,
        .25, .25, 0, 0, 0, 0, 0,
        .25, .25, .25, 0, 0, 0, 0,
        .25, .25, .25, .25, 0, 0, 0,
        0, .25, .25, .25, .25, 1, 0,
        0, 0, .25, .5, .75, 0, 1),
        byrow = T,
        dimnames = list(c("0", "1", "2", "3", "4", "win", "lose"),
        c("0", "1", "2", "3", "4", "win", "lose")))

        M %^% 5 %*% c(1, 0, 0, 0, 0, 0, 0)


        Output:



         [,1]
        0 0.0000000
        1 0.0000000
        2 0.0000000
        3 0.0000000
        4 0.0000000
        win 0.3603516
        lose 0.6396484


        The probability for the win state is consistent with $frac3691024$.




        P.S. I do wonder though if there is a way to derive the distributions over the final states analytically without carrying out the matrix multiplications.







        share|cite|improve this answer














        share|cite|improve this answer



        share|cite|improve this answer








        edited Nov 12 at 18:57

























        answered Nov 12 at 18:46









        Xiubo Zhang

        1335




        1335



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Cross Validated!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstats.stackexchange.com%2fquestions%2f376522%2fprobability-of-the-sum-of-cards%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            ReactJS Fetched API data displays live - need Data displayed static

            Evgeni Malkin