Expected Value for Random Variable for an Algorithm












0















Question:



Algorithm WhoGoesFirst(k):



// k >= 1, the die is fair, and all rolls are independent



Andy rolls the die, let a be the result;



Sean rolls the die, let s be the result;



if a > s



then print Andy goes first;



return k



endif;



if a < s



then print Sean goes first;



return k



endif;



if a = s



then WhoGoesFirst(k + 1)



endif



The algorithm WhoGoesFirst(1) is run, i.e., with k = 1. Define the random variable X to be the value of the output of this algorithm.



What is the expected value E(X) of the random variable X?




Answer: 6/5



Attempt:



I'm not sure how to get an output from this algorithm. Wouldn't the result of rolling the die for both of them have a probability of 1/6? How can I come up with a result that says one person has a higher chance of a roll then the other? And if I assume it is the same, then the recursive function would just loop through the algorithm again. I'm struggling to come up with any output from this algorithm to use to calculate the expected value.










share|cite|improve this question



























    0















    Question:



    Algorithm WhoGoesFirst(k):



    // k >= 1, the die is fair, and all rolls are independent



    Andy rolls the die, let a be the result;



    Sean rolls the die, let s be the result;



    if a > s



    then print Andy goes first;



    return k



    endif;



    if a < s



    then print Sean goes first;



    return k



    endif;



    if a = s



    then WhoGoesFirst(k + 1)



    endif



    The algorithm WhoGoesFirst(1) is run, i.e., with k = 1. Define the random variable X to be the value of the output of this algorithm.



    What is the expected value E(X) of the random variable X?




    Answer: 6/5



    Attempt:



    I'm not sure how to get an output from this algorithm. Wouldn't the result of rolling the die for both of them have a probability of 1/6? How can I come up with a result that says one person has a higher chance of a roll then the other? And if I assume it is the same, then the recursive function would just loop through the algorithm again. I'm struggling to come up with any output from this algorithm to use to calculate the expected value.










    share|cite|improve this question

























      0












      0








      0








      Question:



      Algorithm WhoGoesFirst(k):



      // k >= 1, the die is fair, and all rolls are independent



      Andy rolls the die, let a be the result;



      Sean rolls the die, let s be the result;



      if a > s



      then print Andy goes first;



      return k



      endif;



      if a < s



      then print Sean goes first;



      return k



      endif;



      if a = s



      then WhoGoesFirst(k + 1)



      endif



      The algorithm WhoGoesFirst(1) is run, i.e., with k = 1. Define the random variable X to be the value of the output of this algorithm.



      What is the expected value E(X) of the random variable X?




      Answer: 6/5



      Attempt:



      I'm not sure how to get an output from this algorithm. Wouldn't the result of rolling the die for both of them have a probability of 1/6? How can I come up with a result that says one person has a higher chance of a roll then the other? And if I assume it is the same, then the recursive function would just loop through the algorithm again. I'm struggling to come up with any output from this algorithm to use to calculate the expected value.










      share|cite|improve this question














      Question:



      Algorithm WhoGoesFirst(k):



      // k >= 1, the die is fair, and all rolls are independent



      Andy rolls the die, let a be the result;



      Sean rolls the die, let s be the result;



      if a > s



      then print Andy goes first;



      return k



      endif;



      if a < s



      then print Sean goes first;



      return k



      endif;



      if a = s



      then WhoGoesFirst(k + 1)



      endif



      The algorithm WhoGoesFirst(1) is run, i.e., with k = 1. Define the random variable X to be the value of the output of this algorithm.



      What is the expected value E(X) of the random variable X?




      Answer: 6/5



      Attempt:



      I'm not sure how to get an output from this algorithm. Wouldn't the result of rolling the die for both of them have a probability of 1/6? How can I come up with a result that says one person has a higher chance of a roll then the other? And if I assume it is the same, then the recursive function would just loop through the algorithm again. I'm struggling to come up with any output from this algorithm to use to calculate the expected value.







      probability probability-theory discrete-mathematics random-variables expected-value






      share|cite|improve this question













      share|cite|improve this question











      share|cite|improve this question




      share|cite|improve this question










      asked Nov 27 '18 at 21:29









      Toby

      1577




      1577






















          1 Answer
          1






          active

          oldest

          votes


















          1














          In the first try, with probability 5/6 one is going to roll higher (they roll different) and with probability 1/6 they'll roll the same and the k is going to increase.



          In the next roll, k is going to increase by one so the next who goes next algorithm has expected value of the previous one + 1. Using this we can write



          E(X) = 5/6 * 1 + 1/6 (1 + E(X))



          solving this yields to 6/5



          Alternatively, with probability 1/6 we go to the next roll. Probability that k = 1 is 5/6.



          p(k = 2) is 1/6 * 5/6 (first one drew, second one different)



          p(k = n) is (1/6) ^ (n-1) * 5/6 (first n-1 drew, last one different)



          If you sum the infinite series of k*p(k), you'll get the same result as above.



          Hope it helps






          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: "69"
            };
            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: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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
            },
            noCode: true, onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3016324%2fexpected-value-for-random-variable-for-an-algorithm%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            In the first try, with probability 5/6 one is going to roll higher (they roll different) and with probability 1/6 they'll roll the same and the k is going to increase.



            In the next roll, k is going to increase by one so the next who goes next algorithm has expected value of the previous one + 1. Using this we can write



            E(X) = 5/6 * 1 + 1/6 (1 + E(X))



            solving this yields to 6/5



            Alternatively, with probability 1/6 we go to the next roll. Probability that k = 1 is 5/6.



            p(k = 2) is 1/6 * 5/6 (first one drew, second one different)



            p(k = n) is (1/6) ^ (n-1) * 5/6 (first n-1 drew, last one different)



            If you sum the infinite series of k*p(k), you'll get the same result as above.



            Hope it helps






            share|cite|improve this answer


























              1














              In the first try, with probability 5/6 one is going to roll higher (they roll different) and with probability 1/6 they'll roll the same and the k is going to increase.



              In the next roll, k is going to increase by one so the next who goes next algorithm has expected value of the previous one + 1. Using this we can write



              E(X) = 5/6 * 1 + 1/6 (1 + E(X))



              solving this yields to 6/5



              Alternatively, with probability 1/6 we go to the next roll. Probability that k = 1 is 5/6.



              p(k = 2) is 1/6 * 5/6 (first one drew, second one different)



              p(k = n) is (1/6) ^ (n-1) * 5/6 (first n-1 drew, last one different)



              If you sum the infinite series of k*p(k), you'll get the same result as above.



              Hope it helps






              share|cite|improve this answer
























                1












                1








                1






                In the first try, with probability 5/6 one is going to roll higher (they roll different) and with probability 1/6 they'll roll the same and the k is going to increase.



                In the next roll, k is going to increase by one so the next who goes next algorithm has expected value of the previous one + 1. Using this we can write



                E(X) = 5/6 * 1 + 1/6 (1 + E(X))



                solving this yields to 6/5



                Alternatively, with probability 1/6 we go to the next roll. Probability that k = 1 is 5/6.



                p(k = 2) is 1/6 * 5/6 (first one drew, second one different)



                p(k = n) is (1/6) ^ (n-1) * 5/6 (first n-1 drew, last one different)



                If you sum the infinite series of k*p(k), you'll get the same result as above.



                Hope it helps






                share|cite|improve this answer












                In the first try, with probability 5/6 one is going to roll higher (they roll different) and with probability 1/6 they'll roll the same and the k is going to increase.



                In the next roll, k is going to increase by one so the next who goes next algorithm has expected value of the previous one + 1. Using this we can write



                E(X) = 5/6 * 1 + 1/6 (1 + E(X))



                solving this yields to 6/5



                Alternatively, with probability 1/6 we go to the next roll. Probability that k = 1 is 5/6.



                p(k = 2) is 1/6 * 5/6 (first one drew, second one different)



                p(k = n) is (1/6) ^ (n-1) * 5/6 (first n-1 drew, last one different)



                If you sum the infinite series of k*p(k), you'll get the same result as above.



                Hope it helps







                share|cite|improve this answer












                share|cite|improve this answer



                share|cite|improve this answer










                answered Nov 27 '18 at 21:55









                Ofya

                5048




                5048






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Mathematics Stack Exchange!


                    • 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%2fmath.stackexchange.com%2fquestions%2f3016324%2fexpected-value-for-random-variable-for-an-algorithm%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

                    Quarter-circle Tiles

                    build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

                    Mont Emei