How to simulate the random variable $Y$ using another random variable $X$?











up vote
0
down vote

favorite












Let $X$ be the discrete uniform random variable on taking values in the set ${1,2,3,4,5}.$ We want to simulate the random variable $Y$ which is the discrete uniform random variable taking values in the set ${1,2,3,4,5,6,7}.$



Let generate_X() be a method which generates the numbers from $1$ to $5$ with uniform probability. My goal is to use this method to write a method generate_Y() which generates numbers $1-7$ with uniform probability.



I am not sure how I can 'stretch' the domain from $1-5$ to $1-7$. Any ideas will be much appreciated.










share|cite|improve this question


























    up vote
    0
    down vote

    favorite












    Let $X$ be the discrete uniform random variable on taking values in the set ${1,2,3,4,5}.$ We want to simulate the random variable $Y$ which is the discrete uniform random variable taking values in the set ${1,2,3,4,5,6,7}.$



    Let generate_X() be a method which generates the numbers from $1$ to $5$ with uniform probability. My goal is to use this method to write a method generate_Y() which generates numbers $1-7$ with uniform probability.



    I am not sure how I can 'stretch' the domain from $1-5$ to $1-7$. Any ideas will be much appreciated.










    share|cite|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Let $X$ be the discrete uniform random variable on taking values in the set ${1,2,3,4,5}.$ We want to simulate the random variable $Y$ which is the discrete uniform random variable taking values in the set ${1,2,3,4,5,6,7}.$



      Let generate_X() be a method which generates the numbers from $1$ to $5$ with uniform probability. My goal is to use this method to write a method generate_Y() which generates numbers $1-7$ with uniform probability.



      I am not sure how I can 'stretch' the domain from $1-5$ to $1-7$. Any ideas will be much appreciated.










      share|cite|improve this question













      Let $X$ be the discrete uniform random variable on taking values in the set ${1,2,3,4,5}.$ We want to simulate the random variable $Y$ which is the discrete uniform random variable taking values in the set ${1,2,3,4,5,6,7}.$



      Let generate_X() be a method which generates the numbers from $1$ to $5$ with uniform probability. My goal is to use this method to write a method generate_Y() which generates numbers $1-7$ with uniform probability.



      I am not sure how I can 'stretch' the domain from $1-5$ to $1-7$. Any ideas will be much appreciated.







      simulation






      share|cite|improve this question













      share|cite|improve this question











      share|cite|improve this question




      share|cite|improve this question










      asked Nov 20 at 16:11









      Hello_World

      3,80021630




      3,80021630






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          The standard way to do this is rejection sampling. You simply generate k samples of your "d5" such that you have more than 7 total possible outcomes. Now you pick some multiple of 7 of the total outcomes of your k d5 rolls to assign d7 values to. If you get a different outcome, then you restart.



          For example, with k=2, you roll two d5, you assign values to 21 of the 25 possible outcomes, giving each of the 7 possible d7 rolls 3 outcomes. You discard the other four possible outcomes: if you get those then you have to retry.



          Generalizing this to other situations (besides mapping a discrete uniform distribution into another discrete uniform distribution) requires a significantly different approach. One general approach is to use generate_X() to effectively generate independent Bernoulli(1/2) variables (using exactly this approach, but with a d7 replaced by a d2). Once you have a way to generate such a sequence, you can in principle define generate_Y() in great generality.






          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',
            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%2f3006513%2fhow-to-simulate-the-random-variable-y-using-another-random-variable-x%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








            up vote
            1
            down vote













            The standard way to do this is rejection sampling. You simply generate k samples of your "d5" such that you have more than 7 total possible outcomes. Now you pick some multiple of 7 of the total outcomes of your k d5 rolls to assign d7 values to. If you get a different outcome, then you restart.



            For example, with k=2, you roll two d5, you assign values to 21 of the 25 possible outcomes, giving each of the 7 possible d7 rolls 3 outcomes. You discard the other four possible outcomes: if you get those then you have to retry.



            Generalizing this to other situations (besides mapping a discrete uniform distribution into another discrete uniform distribution) requires a significantly different approach. One general approach is to use generate_X() to effectively generate independent Bernoulli(1/2) variables (using exactly this approach, but with a d7 replaced by a d2). Once you have a way to generate such a sequence, you can in principle define generate_Y() in great generality.






            share|cite|improve this answer



























              up vote
              1
              down vote













              The standard way to do this is rejection sampling. You simply generate k samples of your "d5" such that you have more than 7 total possible outcomes. Now you pick some multiple of 7 of the total outcomes of your k d5 rolls to assign d7 values to. If you get a different outcome, then you restart.



              For example, with k=2, you roll two d5, you assign values to 21 of the 25 possible outcomes, giving each of the 7 possible d7 rolls 3 outcomes. You discard the other four possible outcomes: if you get those then you have to retry.



              Generalizing this to other situations (besides mapping a discrete uniform distribution into another discrete uniform distribution) requires a significantly different approach. One general approach is to use generate_X() to effectively generate independent Bernoulli(1/2) variables (using exactly this approach, but with a d7 replaced by a d2). Once you have a way to generate such a sequence, you can in principle define generate_Y() in great generality.






              share|cite|improve this answer

























                up vote
                1
                down vote










                up vote
                1
                down vote









                The standard way to do this is rejection sampling. You simply generate k samples of your "d5" such that you have more than 7 total possible outcomes. Now you pick some multiple of 7 of the total outcomes of your k d5 rolls to assign d7 values to. If you get a different outcome, then you restart.



                For example, with k=2, you roll two d5, you assign values to 21 of the 25 possible outcomes, giving each of the 7 possible d7 rolls 3 outcomes. You discard the other four possible outcomes: if you get those then you have to retry.



                Generalizing this to other situations (besides mapping a discrete uniform distribution into another discrete uniform distribution) requires a significantly different approach. One general approach is to use generate_X() to effectively generate independent Bernoulli(1/2) variables (using exactly this approach, but with a d7 replaced by a d2). Once you have a way to generate such a sequence, you can in principle define generate_Y() in great generality.






                share|cite|improve this answer














                The standard way to do this is rejection sampling. You simply generate k samples of your "d5" such that you have more than 7 total possible outcomes. Now you pick some multiple of 7 of the total outcomes of your k d5 rolls to assign d7 values to. If you get a different outcome, then you restart.



                For example, with k=2, you roll two d5, you assign values to 21 of the 25 possible outcomes, giving each of the 7 possible d7 rolls 3 outcomes. You discard the other four possible outcomes: if you get those then you have to retry.



                Generalizing this to other situations (besides mapping a discrete uniform distribution into another discrete uniform distribution) requires a significantly different approach. One general approach is to use generate_X() to effectively generate independent Bernoulli(1/2) variables (using exactly this approach, but with a d7 replaced by a d2). Once you have a way to generate such a sequence, you can in principle define generate_Y() in great generality.







                share|cite|improve this answer














                share|cite|improve this answer



                share|cite|improve this answer








                edited Nov 20 at 16:25

























                answered Nov 20 at 16:17









                Ian

                67k25084




                67k25084






























                    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%2f3006513%2fhow-to-simulate-the-random-variable-y-using-another-random-variable-x%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

                    Probability when a professor distributes a quiz and homework assignment to a class of n students.

                    Aardman Animations

                    Are they similar matrix