Range of balls needed in lottery for 0 and 1 match to be equally likely with 5 balls drawn











up vote
2
down vote

favorite
1












The question is if there is a lottery in which 5 balls are drawn randomly without replacement, what is the number range of the balls needed so that matching exactly 0 of those balls or matching exactly 1 of them is equally likely (or as close to equally likely as possible)? Assume all balls are numbered sequentially from 1 to n (such as 1,2,3...n). Solve for n.



I know this can be solved by trial and error but is there a mathematical way to get the answer without first guessing and then making corrections/adjustments?



I was also able to solve it using wolframalpha but how can someone solve it mathematically, either getting an exact same probability for matching exactly 0 or 1 ball(s) or such that the probability of matching exactly 0 or 1 is the closest it can be?



The idea is a hypothetical lottery wants to make it easier to match at least 1 ball so maybe more people play or people that play continue to do so. So the lottery designer is interested to first find out where 0 and 1 matches are about equal, then adjust it slightly to favor at least 1 match.










share|cite|improve this question
























  • What have you tried? Have you considered writing down some formulae in terms of $n$ balls to match $x$ balls?
    – stuart stevenson
    Nov 16 at 18:04










  • Yes I had wolframalpha solve (n choose 5) = 5 * (n choose 4) for n > 10 but when I tried to use pencil and paper to solve it, I ran into some problems. In this example I got lucky and they match but suppose they didn't match but just got close, then I am not sure how to solve it even using wolframalpha without doing some trial and error. I am looking for a mathematical solution to get the answer correct without having to plug and try many times. That is, a general solution that would work even if I used 6 balls instead of 5 for example.
    – David
    Nov 16 at 18:07

















up vote
2
down vote

favorite
1












The question is if there is a lottery in which 5 balls are drawn randomly without replacement, what is the number range of the balls needed so that matching exactly 0 of those balls or matching exactly 1 of them is equally likely (or as close to equally likely as possible)? Assume all balls are numbered sequentially from 1 to n (such as 1,2,3...n). Solve for n.



I know this can be solved by trial and error but is there a mathematical way to get the answer without first guessing and then making corrections/adjustments?



I was also able to solve it using wolframalpha but how can someone solve it mathematically, either getting an exact same probability for matching exactly 0 or 1 ball(s) or such that the probability of matching exactly 0 or 1 is the closest it can be?



The idea is a hypothetical lottery wants to make it easier to match at least 1 ball so maybe more people play or people that play continue to do so. So the lottery designer is interested to first find out where 0 and 1 matches are about equal, then adjust it slightly to favor at least 1 match.










share|cite|improve this question
























  • What have you tried? Have you considered writing down some formulae in terms of $n$ balls to match $x$ balls?
    – stuart stevenson
    Nov 16 at 18:04










  • Yes I had wolframalpha solve (n choose 5) = 5 * (n choose 4) for n > 10 but when I tried to use pencil and paper to solve it, I ran into some problems. In this example I got lucky and they match but suppose they didn't match but just got close, then I am not sure how to solve it even using wolframalpha without doing some trial and error. I am looking for a mathematical solution to get the answer correct without having to plug and try many times. That is, a general solution that would work even if I used 6 balls instead of 5 for example.
    – David
    Nov 16 at 18:07















up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





The question is if there is a lottery in which 5 balls are drawn randomly without replacement, what is the number range of the balls needed so that matching exactly 0 of those balls or matching exactly 1 of them is equally likely (or as close to equally likely as possible)? Assume all balls are numbered sequentially from 1 to n (such as 1,2,3...n). Solve for n.



I know this can be solved by trial and error but is there a mathematical way to get the answer without first guessing and then making corrections/adjustments?



I was also able to solve it using wolframalpha but how can someone solve it mathematically, either getting an exact same probability for matching exactly 0 or 1 ball(s) or such that the probability of matching exactly 0 or 1 is the closest it can be?



The idea is a hypothetical lottery wants to make it easier to match at least 1 ball so maybe more people play or people that play continue to do so. So the lottery designer is interested to first find out where 0 and 1 matches are about equal, then adjust it slightly to favor at least 1 match.










share|cite|improve this question















The question is if there is a lottery in which 5 balls are drawn randomly without replacement, what is the number range of the balls needed so that matching exactly 0 of those balls or matching exactly 1 of them is equally likely (or as close to equally likely as possible)? Assume all balls are numbered sequentially from 1 to n (such as 1,2,3...n). Solve for n.



I know this can be solved by trial and error but is there a mathematical way to get the answer without first guessing and then making corrections/adjustments?



I was also able to solve it using wolframalpha but how can someone solve it mathematically, either getting an exact same probability for matching exactly 0 or 1 ball(s) or such that the probability of matching exactly 0 or 1 is the closest it can be?



The idea is a hypothetical lottery wants to make it easier to match at least 1 ball so maybe more people play or people that play continue to do so. So the lottery designer is interested to first find out where 0 and 1 matches are about equal, then adjust it slightly to favor at least 1 match.







probability






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Nov 16 at 19:04

























asked Nov 16 at 17:59









David

33511033




33511033












  • What have you tried? Have you considered writing down some formulae in terms of $n$ balls to match $x$ balls?
    – stuart stevenson
    Nov 16 at 18:04










  • Yes I had wolframalpha solve (n choose 5) = 5 * (n choose 4) for n > 10 but when I tried to use pencil and paper to solve it, I ran into some problems. In this example I got lucky and they match but suppose they didn't match but just got close, then I am not sure how to solve it even using wolframalpha without doing some trial and error. I am looking for a mathematical solution to get the answer correct without having to plug and try many times. That is, a general solution that would work even if I used 6 balls instead of 5 for example.
    – David
    Nov 16 at 18:07




















  • What have you tried? Have you considered writing down some formulae in terms of $n$ balls to match $x$ balls?
    – stuart stevenson
    Nov 16 at 18:04










  • Yes I had wolframalpha solve (n choose 5) = 5 * (n choose 4) for n > 10 but when I tried to use pencil and paper to solve it, I ran into some problems. In this example I got lucky and they match but suppose they didn't match but just got close, then I am not sure how to solve it even using wolframalpha without doing some trial and error. I am looking for a mathematical solution to get the answer correct without having to plug and try many times. That is, a general solution that would work even if I used 6 balls instead of 5 for example.
    – David
    Nov 16 at 18:07


















What have you tried? Have you considered writing down some formulae in terms of $n$ balls to match $x$ balls?
– stuart stevenson
Nov 16 at 18:04




What have you tried? Have you considered writing down some formulae in terms of $n$ balls to match $x$ balls?
– stuart stevenson
Nov 16 at 18:04












Yes I had wolframalpha solve (n choose 5) = 5 * (n choose 4) for n > 10 but when I tried to use pencil and paper to solve it, I ran into some problems. In this example I got lucky and they match but suppose they didn't match but just got close, then I am not sure how to solve it even using wolframalpha without doing some trial and error. I am looking for a mathematical solution to get the answer correct without having to plug and try many times. That is, a general solution that would work even if I used 6 balls instead of 5 for example.
– David
Nov 16 at 18:07






Yes I had wolframalpha solve (n choose 5) = 5 * (n choose 4) for n > 10 but when I tried to use pencil and paper to solve it, I ran into some problems. In this example I got lucky and they match but suppose they didn't match but just got close, then I am not sure how to solve it even using wolframalpha without doing some trial and error. I am looking for a mathematical solution to get the answer correct without having to plug and try many times. That is, a general solution that would work even if I used 6 balls instead of 5 for example.
– David
Nov 16 at 18:07












2 Answers
2






active

oldest

votes

















up vote
4
down vote



accepted










Here's what I think you're asking, generalized slightly. There are $n$ balls numbered $1, ldots, n$. Lottery players choose $k$ distinct numbers with $k < n$, then $k$ balls are drawn. Tickets are rewarded according to the number of matches.



Each ticket should have the same probability distribution, so wlog assume that the player chooses $1, ldots, k$. Then:




  • The number of zero-match drawings is $binom{n-k}{k}$, the number of $k$-element subsets of ${k+1, ldots, n}$. Note that at least one match is guaranteed unless $2k leq n$.

  • The number of one-match drawings is $k binom{n-k}{k-1}$, the number of one-element subsets of ${1, ldots, k}$ times the number of $k-1$-element subsets of ${k+1, ldots, n}$.


Solving for $n$:
begin{align*}
binom{n-k}{k} &= k binom{n-k}{k-1} \
frac{(n-k)!}{k! (n-2k)!} &= frac{k (n-k)!}{(k-1)! (n-2k+1)!} \
frac{(k-1)!}{k(k!)} &= frac{(n-2k)!}{(n-2k+1)!} \
frac{1}{k^2} &= frac{1}{n - 2k + 1} \
n &= k^2 + 2k - 1
end{align*}



So $n = 34$ for $k = 5$.



If you have the R programming language and the tidyverse package installed, then the following function will let you simulate the lottery. balls and draws are the total number of balls and the number of balls drawn ($n$ and $k$ in my notation above), and trials is the number of simulations to run. The output is a data frame with two columns: num_matches lists integers from 0 to draws, and num_trials shows the number of trials that gave that number of matches with a ticket marked 1, ..., draws.



lottery <- function(balls, draws, trials) { 
tibble(trial=rep(1:trials, each=draws),
result=as.vector(replicate(trials,
sample(1:balls, draws)))) %>%
group_by(trial) %>%
mutate(match=(result<=draws)) %>%
summarize(num_matches=sum(match)) %>%
ungroup() %>%
group_by(num_matches) %>%
summarize(num_trials=n())


}



I tried running this with 200,000 trials and got good results:



> lottery(34, 5, 2e5)
# A tibble: 5 x 2
num_matches num_trials
<int> <int>
1 0 85350
2 1 85338
3 2 26260
4 3 2941
5 4 111

> lottery(62, 7, 2e5)
# A tibble: 6 x 2
num_matches num_trials
<int> <int>
1 0 82073
2 1 82850
3 2 29922
4 3 4777
5 4 364
6 5 14


I'll note that as $k$ increases, the outcomes of this lottery seem to reproduce the Poisson distribution for $lambda = 1$, and the probabilities of $0$ and $1$ matches approach $1/e$. I can't think of a quick explanation for this immediately. The probability of zero matches in this lottery is begin{align*}frac{ binom{k^2 + k - 1}{k}}{binom{k^2 + 2k - 1}{k}} &= frac{ frac{(k^2 + k - 1)!}{k! (k^2-1)!}} {frac{(k^2 + 2k-1)!}{k! (k^2 + k + 1)!}} \
&= frac{(k^2 + k + 1)!^2}{(k^2 + 2k - 1)!(k^2 - 1)! } \
&= frac{k^2 (k^2 + 1) (k^2 + 2) cdots (k^2 + k - 1)}{(k^2 + 2k) (k^2 + 2k + 1) cdots (k^2 + 2k - 1)} \
&= prod_{i=0}^{k-1} frac{k^2+i}{k^2 + 2k + i} \
&= exp left( -sum_{i=1}^{k} log left( 1 - frac{2k}{k^2 + 2k + i} right) right)end{align*}

and perhaps that last sum could be shown to go to $1$ by a clever use of asymptotics.






share|cite|improve this answer























  • Wow so no matter how many balls are drawn, there is an integer solution to the highest numbered ball needed? That is a little surprising to me. For example, if 9 "winning" balls were drawn, then the chances of matching either exactly 0 or exactly 1 of those winning numbers would be equal if there were balls numbered 1 thru 98 inclusive?
    – David
    Nov 16 at 19:01




















up vote
1
down vote













Actually I think I have a solution to this specific problem.



to match exactly 0 balls: ${5 choose 0}$ * ${n choose 5}$



to match exactly 1 ball : ${5 choose 1}$ * ${n choose 4}$



Here n is the number of "losing" balls so the final answer will be 5+n as the highest numbered ball.



So we know ${n choose 5}$ is n (n-1) (n-2) (n-3) (n-4) / 120



and we know $5 * {n choose 4}$ is 5 * n (n-1) (n-2) (n-3) ( ) / 24 (empty parens to show "missing" term)



multiply the 2nd equation by 5/5 to get 25 * n (n-1) (n-2) (n-3) ( ) / 120



now we can drop the /120 since both equations have it and then we multiply both equations by (n-4) (since it is missing from the bottom one)



Now the equations are exactly the same except the top one has an extra (n-4) and the bottom one has a 25 so if we are solving for both equations being equal, that means that 25 = (n-4) so n = 29 which means there have to be 29 losing balls for the lottery to have even chances for exactly 0 or 1 matches, so if the highest numbered ball is 34, I think it is a solution.



However, if the probability of exactly 0 or 1 matching balls is not exactly equal, this method might not work.






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%2f3001446%2frange-of-balls-needed-in-lottery-for-0-and-1-match-to-be-equally-likely-with-5-b%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








    up vote
    4
    down vote



    accepted










    Here's what I think you're asking, generalized slightly. There are $n$ balls numbered $1, ldots, n$. Lottery players choose $k$ distinct numbers with $k < n$, then $k$ balls are drawn. Tickets are rewarded according to the number of matches.



    Each ticket should have the same probability distribution, so wlog assume that the player chooses $1, ldots, k$. Then:




    • The number of zero-match drawings is $binom{n-k}{k}$, the number of $k$-element subsets of ${k+1, ldots, n}$. Note that at least one match is guaranteed unless $2k leq n$.

    • The number of one-match drawings is $k binom{n-k}{k-1}$, the number of one-element subsets of ${1, ldots, k}$ times the number of $k-1$-element subsets of ${k+1, ldots, n}$.


    Solving for $n$:
    begin{align*}
    binom{n-k}{k} &= k binom{n-k}{k-1} \
    frac{(n-k)!}{k! (n-2k)!} &= frac{k (n-k)!}{(k-1)! (n-2k+1)!} \
    frac{(k-1)!}{k(k!)} &= frac{(n-2k)!}{(n-2k+1)!} \
    frac{1}{k^2} &= frac{1}{n - 2k + 1} \
    n &= k^2 + 2k - 1
    end{align*}



    So $n = 34$ for $k = 5$.



    If you have the R programming language and the tidyverse package installed, then the following function will let you simulate the lottery. balls and draws are the total number of balls and the number of balls drawn ($n$ and $k$ in my notation above), and trials is the number of simulations to run. The output is a data frame with two columns: num_matches lists integers from 0 to draws, and num_trials shows the number of trials that gave that number of matches with a ticket marked 1, ..., draws.



    lottery <- function(balls, draws, trials) { 
    tibble(trial=rep(1:trials, each=draws),
    result=as.vector(replicate(trials,
    sample(1:balls, draws)))) %>%
    group_by(trial) %>%
    mutate(match=(result<=draws)) %>%
    summarize(num_matches=sum(match)) %>%
    ungroup() %>%
    group_by(num_matches) %>%
    summarize(num_trials=n())


    }



    I tried running this with 200,000 trials and got good results:



    > lottery(34, 5, 2e5)
    # A tibble: 5 x 2
    num_matches num_trials
    <int> <int>
    1 0 85350
    2 1 85338
    3 2 26260
    4 3 2941
    5 4 111

    > lottery(62, 7, 2e5)
    # A tibble: 6 x 2
    num_matches num_trials
    <int> <int>
    1 0 82073
    2 1 82850
    3 2 29922
    4 3 4777
    5 4 364
    6 5 14


    I'll note that as $k$ increases, the outcomes of this lottery seem to reproduce the Poisson distribution for $lambda = 1$, and the probabilities of $0$ and $1$ matches approach $1/e$. I can't think of a quick explanation for this immediately. The probability of zero matches in this lottery is begin{align*}frac{ binom{k^2 + k - 1}{k}}{binom{k^2 + 2k - 1}{k}} &= frac{ frac{(k^2 + k - 1)!}{k! (k^2-1)!}} {frac{(k^2 + 2k-1)!}{k! (k^2 + k + 1)!}} \
    &= frac{(k^2 + k + 1)!^2}{(k^2 + 2k - 1)!(k^2 - 1)! } \
    &= frac{k^2 (k^2 + 1) (k^2 + 2) cdots (k^2 + k - 1)}{(k^2 + 2k) (k^2 + 2k + 1) cdots (k^2 + 2k - 1)} \
    &= prod_{i=0}^{k-1} frac{k^2+i}{k^2 + 2k + i} \
    &= exp left( -sum_{i=1}^{k} log left( 1 - frac{2k}{k^2 + 2k + i} right) right)end{align*}

    and perhaps that last sum could be shown to go to $1$ by a clever use of asymptotics.






    share|cite|improve this answer























    • Wow so no matter how many balls are drawn, there is an integer solution to the highest numbered ball needed? That is a little surprising to me. For example, if 9 "winning" balls were drawn, then the chances of matching either exactly 0 or exactly 1 of those winning numbers would be equal if there were balls numbered 1 thru 98 inclusive?
      – David
      Nov 16 at 19:01

















    up vote
    4
    down vote



    accepted










    Here's what I think you're asking, generalized slightly. There are $n$ balls numbered $1, ldots, n$. Lottery players choose $k$ distinct numbers with $k < n$, then $k$ balls are drawn. Tickets are rewarded according to the number of matches.



    Each ticket should have the same probability distribution, so wlog assume that the player chooses $1, ldots, k$. Then:




    • The number of zero-match drawings is $binom{n-k}{k}$, the number of $k$-element subsets of ${k+1, ldots, n}$. Note that at least one match is guaranteed unless $2k leq n$.

    • The number of one-match drawings is $k binom{n-k}{k-1}$, the number of one-element subsets of ${1, ldots, k}$ times the number of $k-1$-element subsets of ${k+1, ldots, n}$.


    Solving for $n$:
    begin{align*}
    binom{n-k}{k} &= k binom{n-k}{k-1} \
    frac{(n-k)!}{k! (n-2k)!} &= frac{k (n-k)!}{(k-1)! (n-2k+1)!} \
    frac{(k-1)!}{k(k!)} &= frac{(n-2k)!}{(n-2k+1)!} \
    frac{1}{k^2} &= frac{1}{n - 2k + 1} \
    n &= k^2 + 2k - 1
    end{align*}



    So $n = 34$ for $k = 5$.



    If you have the R programming language and the tidyverse package installed, then the following function will let you simulate the lottery. balls and draws are the total number of balls and the number of balls drawn ($n$ and $k$ in my notation above), and trials is the number of simulations to run. The output is a data frame with two columns: num_matches lists integers from 0 to draws, and num_trials shows the number of trials that gave that number of matches with a ticket marked 1, ..., draws.



    lottery <- function(balls, draws, trials) { 
    tibble(trial=rep(1:trials, each=draws),
    result=as.vector(replicate(trials,
    sample(1:balls, draws)))) %>%
    group_by(trial) %>%
    mutate(match=(result<=draws)) %>%
    summarize(num_matches=sum(match)) %>%
    ungroup() %>%
    group_by(num_matches) %>%
    summarize(num_trials=n())


    }



    I tried running this with 200,000 trials and got good results:



    > lottery(34, 5, 2e5)
    # A tibble: 5 x 2
    num_matches num_trials
    <int> <int>
    1 0 85350
    2 1 85338
    3 2 26260
    4 3 2941
    5 4 111

    > lottery(62, 7, 2e5)
    # A tibble: 6 x 2
    num_matches num_trials
    <int> <int>
    1 0 82073
    2 1 82850
    3 2 29922
    4 3 4777
    5 4 364
    6 5 14


    I'll note that as $k$ increases, the outcomes of this lottery seem to reproduce the Poisson distribution for $lambda = 1$, and the probabilities of $0$ and $1$ matches approach $1/e$. I can't think of a quick explanation for this immediately. The probability of zero matches in this lottery is begin{align*}frac{ binom{k^2 + k - 1}{k}}{binom{k^2 + 2k - 1}{k}} &= frac{ frac{(k^2 + k - 1)!}{k! (k^2-1)!}} {frac{(k^2 + 2k-1)!}{k! (k^2 + k + 1)!}} \
    &= frac{(k^2 + k + 1)!^2}{(k^2 + 2k - 1)!(k^2 - 1)! } \
    &= frac{k^2 (k^2 + 1) (k^2 + 2) cdots (k^2 + k - 1)}{(k^2 + 2k) (k^2 + 2k + 1) cdots (k^2 + 2k - 1)} \
    &= prod_{i=0}^{k-1} frac{k^2+i}{k^2 + 2k + i} \
    &= exp left( -sum_{i=1}^{k} log left( 1 - frac{2k}{k^2 + 2k + i} right) right)end{align*}

    and perhaps that last sum could be shown to go to $1$ by a clever use of asymptotics.






    share|cite|improve this answer























    • Wow so no matter how many balls are drawn, there is an integer solution to the highest numbered ball needed? That is a little surprising to me. For example, if 9 "winning" balls were drawn, then the chances of matching either exactly 0 or exactly 1 of those winning numbers would be equal if there were balls numbered 1 thru 98 inclusive?
      – David
      Nov 16 at 19:01















    up vote
    4
    down vote



    accepted







    up vote
    4
    down vote



    accepted






    Here's what I think you're asking, generalized slightly. There are $n$ balls numbered $1, ldots, n$. Lottery players choose $k$ distinct numbers with $k < n$, then $k$ balls are drawn. Tickets are rewarded according to the number of matches.



    Each ticket should have the same probability distribution, so wlog assume that the player chooses $1, ldots, k$. Then:




    • The number of zero-match drawings is $binom{n-k}{k}$, the number of $k$-element subsets of ${k+1, ldots, n}$. Note that at least one match is guaranteed unless $2k leq n$.

    • The number of one-match drawings is $k binom{n-k}{k-1}$, the number of one-element subsets of ${1, ldots, k}$ times the number of $k-1$-element subsets of ${k+1, ldots, n}$.


    Solving for $n$:
    begin{align*}
    binom{n-k}{k} &= k binom{n-k}{k-1} \
    frac{(n-k)!}{k! (n-2k)!} &= frac{k (n-k)!}{(k-1)! (n-2k+1)!} \
    frac{(k-1)!}{k(k!)} &= frac{(n-2k)!}{(n-2k+1)!} \
    frac{1}{k^2} &= frac{1}{n - 2k + 1} \
    n &= k^2 + 2k - 1
    end{align*}



    So $n = 34$ for $k = 5$.



    If you have the R programming language and the tidyverse package installed, then the following function will let you simulate the lottery. balls and draws are the total number of balls and the number of balls drawn ($n$ and $k$ in my notation above), and trials is the number of simulations to run. The output is a data frame with two columns: num_matches lists integers from 0 to draws, and num_trials shows the number of trials that gave that number of matches with a ticket marked 1, ..., draws.



    lottery <- function(balls, draws, trials) { 
    tibble(trial=rep(1:trials, each=draws),
    result=as.vector(replicate(trials,
    sample(1:balls, draws)))) %>%
    group_by(trial) %>%
    mutate(match=(result<=draws)) %>%
    summarize(num_matches=sum(match)) %>%
    ungroup() %>%
    group_by(num_matches) %>%
    summarize(num_trials=n())


    }



    I tried running this with 200,000 trials and got good results:



    > lottery(34, 5, 2e5)
    # A tibble: 5 x 2
    num_matches num_trials
    <int> <int>
    1 0 85350
    2 1 85338
    3 2 26260
    4 3 2941
    5 4 111

    > lottery(62, 7, 2e5)
    # A tibble: 6 x 2
    num_matches num_trials
    <int> <int>
    1 0 82073
    2 1 82850
    3 2 29922
    4 3 4777
    5 4 364
    6 5 14


    I'll note that as $k$ increases, the outcomes of this lottery seem to reproduce the Poisson distribution for $lambda = 1$, and the probabilities of $0$ and $1$ matches approach $1/e$. I can't think of a quick explanation for this immediately. The probability of zero matches in this lottery is begin{align*}frac{ binom{k^2 + k - 1}{k}}{binom{k^2 + 2k - 1}{k}} &= frac{ frac{(k^2 + k - 1)!}{k! (k^2-1)!}} {frac{(k^2 + 2k-1)!}{k! (k^2 + k + 1)!}} \
    &= frac{(k^2 + k + 1)!^2}{(k^2 + 2k - 1)!(k^2 - 1)! } \
    &= frac{k^2 (k^2 + 1) (k^2 + 2) cdots (k^2 + k - 1)}{(k^2 + 2k) (k^2 + 2k + 1) cdots (k^2 + 2k - 1)} \
    &= prod_{i=0}^{k-1} frac{k^2+i}{k^2 + 2k + i} \
    &= exp left( -sum_{i=1}^{k} log left( 1 - frac{2k}{k^2 + 2k + i} right) right)end{align*}

    and perhaps that last sum could be shown to go to $1$ by a clever use of asymptotics.






    share|cite|improve this answer














    Here's what I think you're asking, generalized slightly. There are $n$ balls numbered $1, ldots, n$. Lottery players choose $k$ distinct numbers with $k < n$, then $k$ balls are drawn. Tickets are rewarded according to the number of matches.



    Each ticket should have the same probability distribution, so wlog assume that the player chooses $1, ldots, k$. Then:




    • The number of zero-match drawings is $binom{n-k}{k}$, the number of $k$-element subsets of ${k+1, ldots, n}$. Note that at least one match is guaranteed unless $2k leq n$.

    • The number of one-match drawings is $k binom{n-k}{k-1}$, the number of one-element subsets of ${1, ldots, k}$ times the number of $k-1$-element subsets of ${k+1, ldots, n}$.


    Solving for $n$:
    begin{align*}
    binom{n-k}{k} &= k binom{n-k}{k-1} \
    frac{(n-k)!}{k! (n-2k)!} &= frac{k (n-k)!}{(k-1)! (n-2k+1)!} \
    frac{(k-1)!}{k(k!)} &= frac{(n-2k)!}{(n-2k+1)!} \
    frac{1}{k^2} &= frac{1}{n - 2k + 1} \
    n &= k^2 + 2k - 1
    end{align*}



    So $n = 34$ for $k = 5$.



    If you have the R programming language and the tidyverse package installed, then the following function will let you simulate the lottery. balls and draws are the total number of balls and the number of balls drawn ($n$ and $k$ in my notation above), and trials is the number of simulations to run. The output is a data frame with two columns: num_matches lists integers from 0 to draws, and num_trials shows the number of trials that gave that number of matches with a ticket marked 1, ..., draws.



    lottery <- function(balls, draws, trials) { 
    tibble(trial=rep(1:trials, each=draws),
    result=as.vector(replicate(trials,
    sample(1:balls, draws)))) %>%
    group_by(trial) %>%
    mutate(match=(result<=draws)) %>%
    summarize(num_matches=sum(match)) %>%
    ungroup() %>%
    group_by(num_matches) %>%
    summarize(num_trials=n())


    }



    I tried running this with 200,000 trials and got good results:



    > lottery(34, 5, 2e5)
    # A tibble: 5 x 2
    num_matches num_trials
    <int> <int>
    1 0 85350
    2 1 85338
    3 2 26260
    4 3 2941
    5 4 111

    > lottery(62, 7, 2e5)
    # A tibble: 6 x 2
    num_matches num_trials
    <int> <int>
    1 0 82073
    2 1 82850
    3 2 29922
    4 3 4777
    5 4 364
    6 5 14


    I'll note that as $k$ increases, the outcomes of this lottery seem to reproduce the Poisson distribution for $lambda = 1$, and the probabilities of $0$ and $1$ matches approach $1/e$. I can't think of a quick explanation for this immediately. The probability of zero matches in this lottery is begin{align*}frac{ binom{k^2 + k - 1}{k}}{binom{k^2 + 2k - 1}{k}} &= frac{ frac{(k^2 + k - 1)!}{k! (k^2-1)!}} {frac{(k^2 + 2k-1)!}{k! (k^2 + k + 1)!}} \
    &= frac{(k^2 + k + 1)!^2}{(k^2 + 2k - 1)!(k^2 - 1)! } \
    &= frac{k^2 (k^2 + 1) (k^2 + 2) cdots (k^2 + k - 1)}{(k^2 + 2k) (k^2 + 2k + 1) cdots (k^2 + 2k - 1)} \
    &= prod_{i=0}^{k-1} frac{k^2+i}{k^2 + 2k + i} \
    &= exp left( -sum_{i=1}^{k} log left( 1 - frac{2k}{k^2 + 2k + i} right) right)end{align*}

    and perhaps that last sum could be shown to go to $1$ by a clever use of asymptotics.







    share|cite|improve this answer














    share|cite|improve this answer



    share|cite|improve this answer








    edited Nov 16 at 19:24

























    answered Nov 16 at 18:37









    Connor Harris

    4,149723




    4,149723












    • Wow so no matter how many balls are drawn, there is an integer solution to the highest numbered ball needed? That is a little surprising to me. For example, if 9 "winning" balls were drawn, then the chances of matching either exactly 0 or exactly 1 of those winning numbers would be equal if there were balls numbered 1 thru 98 inclusive?
      – David
      Nov 16 at 19:01




















    • Wow so no matter how many balls are drawn, there is an integer solution to the highest numbered ball needed? That is a little surprising to me. For example, if 9 "winning" balls were drawn, then the chances of matching either exactly 0 or exactly 1 of those winning numbers would be equal if there were balls numbered 1 thru 98 inclusive?
      – David
      Nov 16 at 19:01


















    Wow so no matter how many balls are drawn, there is an integer solution to the highest numbered ball needed? That is a little surprising to me. For example, if 9 "winning" balls were drawn, then the chances of matching either exactly 0 or exactly 1 of those winning numbers would be equal if there were balls numbered 1 thru 98 inclusive?
    – David
    Nov 16 at 19:01






    Wow so no matter how many balls are drawn, there is an integer solution to the highest numbered ball needed? That is a little surprising to me. For example, if 9 "winning" balls were drawn, then the chances of matching either exactly 0 or exactly 1 of those winning numbers would be equal if there were balls numbered 1 thru 98 inclusive?
    – David
    Nov 16 at 19:01












    up vote
    1
    down vote













    Actually I think I have a solution to this specific problem.



    to match exactly 0 balls: ${5 choose 0}$ * ${n choose 5}$



    to match exactly 1 ball : ${5 choose 1}$ * ${n choose 4}$



    Here n is the number of "losing" balls so the final answer will be 5+n as the highest numbered ball.



    So we know ${n choose 5}$ is n (n-1) (n-2) (n-3) (n-4) / 120



    and we know $5 * {n choose 4}$ is 5 * n (n-1) (n-2) (n-3) ( ) / 24 (empty parens to show "missing" term)



    multiply the 2nd equation by 5/5 to get 25 * n (n-1) (n-2) (n-3) ( ) / 120



    now we can drop the /120 since both equations have it and then we multiply both equations by (n-4) (since it is missing from the bottom one)



    Now the equations are exactly the same except the top one has an extra (n-4) and the bottom one has a 25 so if we are solving for both equations being equal, that means that 25 = (n-4) so n = 29 which means there have to be 29 losing balls for the lottery to have even chances for exactly 0 or 1 matches, so if the highest numbered ball is 34, I think it is a solution.



    However, if the probability of exactly 0 or 1 matching balls is not exactly equal, this method might not work.






    share|cite|improve this answer



























      up vote
      1
      down vote













      Actually I think I have a solution to this specific problem.



      to match exactly 0 balls: ${5 choose 0}$ * ${n choose 5}$



      to match exactly 1 ball : ${5 choose 1}$ * ${n choose 4}$



      Here n is the number of "losing" balls so the final answer will be 5+n as the highest numbered ball.



      So we know ${n choose 5}$ is n (n-1) (n-2) (n-3) (n-4) / 120



      and we know $5 * {n choose 4}$ is 5 * n (n-1) (n-2) (n-3) ( ) / 24 (empty parens to show "missing" term)



      multiply the 2nd equation by 5/5 to get 25 * n (n-1) (n-2) (n-3) ( ) / 120



      now we can drop the /120 since both equations have it and then we multiply both equations by (n-4) (since it is missing from the bottom one)



      Now the equations are exactly the same except the top one has an extra (n-4) and the bottom one has a 25 so if we are solving for both equations being equal, that means that 25 = (n-4) so n = 29 which means there have to be 29 losing balls for the lottery to have even chances for exactly 0 or 1 matches, so if the highest numbered ball is 34, I think it is a solution.



      However, if the probability of exactly 0 or 1 matching balls is not exactly equal, this method might not work.






      share|cite|improve this answer

























        up vote
        1
        down vote










        up vote
        1
        down vote









        Actually I think I have a solution to this specific problem.



        to match exactly 0 balls: ${5 choose 0}$ * ${n choose 5}$



        to match exactly 1 ball : ${5 choose 1}$ * ${n choose 4}$



        Here n is the number of "losing" balls so the final answer will be 5+n as the highest numbered ball.



        So we know ${n choose 5}$ is n (n-1) (n-2) (n-3) (n-4) / 120



        and we know $5 * {n choose 4}$ is 5 * n (n-1) (n-2) (n-3) ( ) / 24 (empty parens to show "missing" term)



        multiply the 2nd equation by 5/5 to get 25 * n (n-1) (n-2) (n-3) ( ) / 120



        now we can drop the /120 since both equations have it and then we multiply both equations by (n-4) (since it is missing from the bottom one)



        Now the equations are exactly the same except the top one has an extra (n-4) and the bottom one has a 25 so if we are solving for both equations being equal, that means that 25 = (n-4) so n = 29 which means there have to be 29 losing balls for the lottery to have even chances for exactly 0 or 1 matches, so if the highest numbered ball is 34, I think it is a solution.



        However, if the probability of exactly 0 or 1 matching balls is not exactly equal, this method might not work.






        share|cite|improve this answer














        Actually I think I have a solution to this specific problem.



        to match exactly 0 balls: ${5 choose 0}$ * ${n choose 5}$



        to match exactly 1 ball : ${5 choose 1}$ * ${n choose 4}$



        Here n is the number of "losing" balls so the final answer will be 5+n as the highest numbered ball.



        So we know ${n choose 5}$ is n (n-1) (n-2) (n-3) (n-4) / 120



        and we know $5 * {n choose 4}$ is 5 * n (n-1) (n-2) (n-3) ( ) / 24 (empty parens to show "missing" term)



        multiply the 2nd equation by 5/5 to get 25 * n (n-1) (n-2) (n-3) ( ) / 120



        now we can drop the /120 since both equations have it and then we multiply both equations by (n-4) (since it is missing from the bottom one)



        Now the equations are exactly the same except the top one has an extra (n-4) and the bottom one has a 25 so if we are solving for both equations being equal, that means that 25 = (n-4) so n = 29 which means there have to be 29 losing balls for the lottery to have even chances for exactly 0 or 1 matches, so if the highest numbered ball is 34, I think it is a solution.



        However, if the probability of exactly 0 or 1 matching balls is not exactly equal, this method might not work.







        share|cite|improve this answer














        share|cite|improve this answer



        share|cite|improve this answer








        edited Nov 16 at 23:29

























        answered Nov 16 at 18:39









        David

        33511033




        33511033






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3001446%2frange-of-balls-needed-in-lottery-for-0-and-1-match-to-be-equally-likely-with-5-b%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

            Bundesstraße 106

            Verónica Boquete

            Ida-Boy-Ed-Garten