What is the probability of three consecutive results X and two results Y in an event?











up vote
4
down vote

favorite












I have N number of days where three different events X,Y,Z can occur in each day. A is a set of possible occurrences of length N. I want to calculate the number of ways where:




  1. Y does NOT happen twice or more in these number of days N

  2. X does NOT happen three times consecutively in these number of days N


So, one acceptable way where N=5 is A=[Z,Z,Z,Y,Z]. One unacceptable way is where A=[X,X,X,Z,Z].



I was just going to find the number of days where Y can occur two time, plus the number of days where x happens three times consecutively, add then and subtract that from the total number of days possible, but that wouldn't give me the right answer because it is possible for there to be overlap in those days. I don't remember the right formula I need.










share|cite|improve this question

















This question has an open bounty worth +50
reputation from user3026388 ending in 3 days.


Looking for an answer drawing from credible and/or official sources.
















  • To clarify, Y happens at most one time TOTAL, while X can happen many times, bot not three times in a row, correct?
    – Todor Markov
    Nov 20 at 12:44










  • This is a repeat of math.stackexchange.com/questions/2250558/… which is also equivalent to projecteuler.net/problem=191
    – antkam
    Nov 20 at 14:27










  • @TodorMarkov Yes, that is correct
    – user3026388
    Nov 20 at 16:37










  • Do you mean Y happens exactly twice or at least twice?
    – Mostafa Ayaz
    2 days ago










  • @MostafaAyaz I do not want Y to happen 2 or more times. Hope that clarifies
    – user3026388
    2 days ago















up vote
4
down vote

favorite












I have N number of days where three different events X,Y,Z can occur in each day. A is a set of possible occurrences of length N. I want to calculate the number of ways where:




  1. Y does NOT happen twice or more in these number of days N

  2. X does NOT happen three times consecutively in these number of days N


So, one acceptable way where N=5 is A=[Z,Z,Z,Y,Z]. One unacceptable way is where A=[X,X,X,Z,Z].



I was just going to find the number of days where Y can occur two time, plus the number of days where x happens three times consecutively, add then and subtract that from the total number of days possible, but that wouldn't give me the right answer because it is possible for there to be overlap in those days. I don't remember the right formula I need.










share|cite|improve this question

















This question has an open bounty worth +50
reputation from user3026388 ending in 3 days.


Looking for an answer drawing from credible and/or official sources.
















  • To clarify, Y happens at most one time TOTAL, while X can happen many times, bot not three times in a row, correct?
    – Todor Markov
    Nov 20 at 12:44










  • This is a repeat of math.stackexchange.com/questions/2250558/… which is also equivalent to projecteuler.net/problem=191
    – antkam
    Nov 20 at 14:27










  • @TodorMarkov Yes, that is correct
    – user3026388
    Nov 20 at 16:37










  • Do you mean Y happens exactly twice or at least twice?
    – Mostafa Ayaz
    2 days ago










  • @MostafaAyaz I do not want Y to happen 2 or more times. Hope that clarifies
    – user3026388
    2 days ago













up vote
4
down vote

favorite









up vote
4
down vote

favorite











I have N number of days where three different events X,Y,Z can occur in each day. A is a set of possible occurrences of length N. I want to calculate the number of ways where:




  1. Y does NOT happen twice or more in these number of days N

  2. X does NOT happen three times consecutively in these number of days N


So, one acceptable way where N=5 is A=[Z,Z,Z,Y,Z]. One unacceptable way is where A=[X,X,X,Z,Z].



I was just going to find the number of days where Y can occur two time, plus the number of days where x happens three times consecutively, add then and subtract that from the total number of days possible, but that wouldn't give me the right answer because it is possible for there to be overlap in those days. I don't remember the right formula I need.










share|cite|improve this question















I have N number of days where three different events X,Y,Z can occur in each day. A is a set of possible occurrences of length N. I want to calculate the number of ways where:




  1. Y does NOT happen twice or more in these number of days N

  2. X does NOT happen three times consecutively in these number of days N


So, one acceptable way where N=5 is A=[Z,Z,Z,Y,Z]. One unacceptable way is where A=[X,X,X,Z,Z].



I was just going to find the number of days where Y can occur two time, plus the number of days where x happens three times consecutively, add then and subtract that from the total number of days possible, but that wouldn't give me the right answer because it is possible for there to be overlap in those days. I don't remember the right formula I need.







probability






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited 2 days ago

























asked Nov 14 at 23:40









user3026388

9610




9610






This question has an open bounty worth +50
reputation from user3026388 ending in 3 days.


Looking for an answer drawing from credible and/or official sources.








This question has an open bounty worth +50
reputation from user3026388 ending in 3 days.


Looking for an answer drawing from credible and/or official sources.














  • To clarify, Y happens at most one time TOTAL, while X can happen many times, bot not three times in a row, correct?
    – Todor Markov
    Nov 20 at 12:44










  • This is a repeat of math.stackexchange.com/questions/2250558/… which is also equivalent to projecteuler.net/problem=191
    – antkam
    Nov 20 at 14:27










  • @TodorMarkov Yes, that is correct
    – user3026388
    Nov 20 at 16:37










  • Do you mean Y happens exactly twice or at least twice?
    – Mostafa Ayaz
    2 days ago










  • @MostafaAyaz I do not want Y to happen 2 or more times. Hope that clarifies
    – user3026388
    2 days ago


















  • To clarify, Y happens at most one time TOTAL, while X can happen many times, bot not three times in a row, correct?
    – Todor Markov
    Nov 20 at 12:44










  • This is a repeat of math.stackexchange.com/questions/2250558/… which is also equivalent to projecteuler.net/problem=191
    – antkam
    Nov 20 at 14:27










  • @TodorMarkov Yes, that is correct
    – user3026388
    Nov 20 at 16:37










  • Do you mean Y happens exactly twice or at least twice?
    – Mostafa Ayaz
    2 days ago










  • @MostafaAyaz I do not want Y to happen 2 or more times. Hope that clarifies
    – user3026388
    2 days ago
















To clarify, Y happens at most one time TOTAL, while X can happen many times, bot not three times in a row, correct?
– Todor Markov
Nov 20 at 12:44




To clarify, Y happens at most one time TOTAL, while X can happen many times, bot not three times in a row, correct?
– Todor Markov
Nov 20 at 12:44












This is a repeat of math.stackexchange.com/questions/2250558/… which is also equivalent to projecteuler.net/problem=191
– antkam
Nov 20 at 14:27




This is a repeat of math.stackexchange.com/questions/2250558/… which is also equivalent to projecteuler.net/problem=191
– antkam
Nov 20 at 14:27












@TodorMarkov Yes, that is correct
– user3026388
Nov 20 at 16:37




@TodorMarkov Yes, that is correct
– user3026388
Nov 20 at 16:37












Do you mean Y happens exactly twice or at least twice?
– Mostafa Ayaz
2 days ago




Do you mean Y happens exactly twice or at least twice?
– Mostafa Ayaz
2 days ago












@MostafaAyaz I do not want Y to happen 2 or more times. Hope that clarifies
– user3026388
2 days ago




@MostafaAyaz I do not want Y to happen 2 or more times. Hope that clarifies
– user3026388
2 days ago










1 Answer
1






active

oldest

votes

















up vote
1
down vote













a) Y cannot appear two or more times



Then

- if Y does not appear, we are left with a binary (X,Z) string of length $n=N$;

- if Y appears once, by removing it, we are left with two binary (X,Z) string of length $n$ and $N-n-1$, with $0 le n le N-1$.



b) The string does not contain one (or more) runs of three (or more) consecutive X



Consider a binary string with $s$ $X; leftrightarrow ,1$'s and $m$ $Z; leftrightarrow ,0$'s in total.

The number of these strings in which the runs of consecutive ones have a length not greater than $r$, is given by
$$N_{,b} (s,r,m+1) = text{No}text{. of solutions to};left{ begin{gathered}
0 leqslant text{integer }x_{,j} leqslant r hfill \
x_{,1} + x_{,2} + cdots + x_{,m+1} = s hfill \
end{gathered} right.$$

which is equal to
$$
N_b (s,r,m + 1)quad left| {;0 leqslant text{integers }s,m,r} right.quad
= sumlimits_{left( {0, leqslant } right),,k,,left( { leqslant ,frac{s}{r}, leqslant ,m + 1} right)}
{left( { - 1} right)^k left( begin{gathered}
m + 1 \
k \
end{gathered} right)left( begin{gathered}
s + m - kleft( {r + 1} right) \
s - kleft( {r + 1} right) \
end{gathered} right)}
$$

as thoroughly explained in this and this other posts.



In our case $r=2$, and for a string of length $n$ we shall put $m=n-s$ and sum for $0 le s le n$
$$
S(n)quad = sumlimits_{left( {0, le } right),s,left( { le ,n} right)} {sumlimits_{left( {0, le } right),,k,,left( { le ,{s over 2},} right)}
{left( { - 1} right)^k binom{n-s+1}{k} binom{n-3k}{s-3k}
} }
$$



For $n=0,1,2,cdots ,6$ we obtain that $S(n)$ equals
$$1, 2, 4, 7, 13, 24, 44, cdots$$



c) Conclusion



Standing what said in point a) we can conclude that the sought number $T(N)$ is given by
$$
T(n) = S(N) + sumlimits_{0, le ,n, le ,N - 1} {S(n),S(N - 1 - n)}
$$



For $n=0,1,2,cdots ,8$ $T(n)$ results to be
$$1, 3, 8, 19, 43, 94, 200, 418, 861, cdots$$
which checks correctly with a direct count.






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%2f2998975%2fwhat-is-the-probability-of-three-consecutive-results-x-and-two-results-y-in-an-e%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













    a) Y cannot appear two or more times



    Then

    - if Y does not appear, we are left with a binary (X,Z) string of length $n=N$;

    - if Y appears once, by removing it, we are left with two binary (X,Z) string of length $n$ and $N-n-1$, with $0 le n le N-1$.



    b) The string does not contain one (or more) runs of three (or more) consecutive X



    Consider a binary string with $s$ $X; leftrightarrow ,1$'s and $m$ $Z; leftrightarrow ,0$'s in total.

    The number of these strings in which the runs of consecutive ones have a length not greater than $r$, is given by
    $$N_{,b} (s,r,m+1) = text{No}text{. of solutions to};left{ begin{gathered}
    0 leqslant text{integer }x_{,j} leqslant r hfill \
    x_{,1} + x_{,2} + cdots + x_{,m+1} = s hfill \
    end{gathered} right.$$

    which is equal to
    $$
    N_b (s,r,m + 1)quad left| {;0 leqslant text{integers }s,m,r} right.quad
    = sumlimits_{left( {0, leqslant } right),,k,,left( { leqslant ,frac{s}{r}, leqslant ,m + 1} right)}
    {left( { - 1} right)^k left( begin{gathered}
    m + 1 \
    k \
    end{gathered} right)left( begin{gathered}
    s + m - kleft( {r + 1} right) \
    s - kleft( {r + 1} right) \
    end{gathered} right)}
    $$

    as thoroughly explained in this and this other posts.



    In our case $r=2$, and for a string of length $n$ we shall put $m=n-s$ and sum for $0 le s le n$
    $$
    S(n)quad = sumlimits_{left( {0, le } right),s,left( { le ,n} right)} {sumlimits_{left( {0, le } right),,k,,left( { le ,{s over 2},} right)}
    {left( { - 1} right)^k binom{n-s+1}{k} binom{n-3k}{s-3k}
    } }
    $$



    For $n=0,1,2,cdots ,6$ we obtain that $S(n)$ equals
    $$1, 2, 4, 7, 13, 24, 44, cdots$$



    c) Conclusion



    Standing what said in point a) we can conclude that the sought number $T(N)$ is given by
    $$
    T(n) = S(N) + sumlimits_{0, le ,n, le ,N - 1} {S(n),S(N - 1 - n)}
    $$



    For $n=0,1,2,cdots ,8$ $T(n)$ results to be
    $$1, 3, 8, 19, 43, 94, 200, 418, 861, cdots$$
    which checks correctly with a direct count.






    share|cite|improve this answer



























      up vote
      1
      down vote













      a) Y cannot appear two or more times



      Then

      - if Y does not appear, we are left with a binary (X,Z) string of length $n=N$;

      - if Y appears once, by removing it, we are left with two binary (X,Z) string of length $n$ and $N-n-1$, with $0 le n le N-1$.



      b) The string does not contain one (or more) runs of three (or more) consecutive X



      Consider a binary string with $s$ $X; leftrightarrow ,1$'s and $m$ $Z; leftrightarrow ,0$'s in total.

      The number of these strings in which the runs of consecutive ones have a length not greater than $r$, is given by
      $$N_{,b} (s,r,m+1) = text{No}text{. of solutions to};left{ begin{gathered}
      0 leqslant text{integer }x_{,j} leqslant r hfill \
      x_{,1} + x_{,2} + cdots + x_{,m+1} = s hfill \
      end{gathered} right.$$

      which is equal to
      $$
      N_b (s,r,m + 1)quad left| {;0 leqslant text{integers }s,m,r} right.quad
      = sumlimits_{left( {0, leqslant } right),,k,,left( { leqslant ,frac{s}{r}, leqslant ,m + 1} right)}
      {left( { - 1} right)^k left( begin{gathered}
      m + 1 \
      k \
      end{gathered} right)left( begin{gathered}
      s + m - kleft( {r + 1} right) \
      s - kleft( {r + 1} right) \
      end{gathered} right)}
      $$

      as thoroughly explained in this and this other posts.



      In our case $r=2$, and for a string of length $n$ we shall put $m=n-s$ and sum for $0 le s le n$
      $$
      S(n)quad = sumlimits_{left( {0, le } right),s,left( { le ,n} right)} {sumlimits_{left( {0, le } right),,k,,left( { le ,{s over 2},} right)}
      {left( { - 1} right)^k binom{n-s+1}{k} binom{n-3k}{s-3k}
      } }
      $$



      For $n=0,1,2,cdots ,6$ we obtain that $S(n)$ equals
      $$1, 2, 4, 7, 13, 24, 44, cdots$$



      c) Conclusion



      Standing what said in point a) we can conclude that the sought number $T(N)$ is given by
      $$
      T(n) = S(N) + sumlimits_{0, le ,n, le ,N - 1} {S(n),S(N - 1 - n)}
      $$



      For $n=0,1,2,cdots ,8$ $T(n)$ results to be
      $$1, 3, 8, 19, 43, 94, 200, 418, 861, cdots$$
      which checks correctly with a direct count.






      share|cite|improve this answer

























        up vote
        1
        down vote










        up vote
        1
        down vote









        a) Y cannot appear two or more times



        Then

        - if Y does not appear, we are left with a binary (X,Z) string of length $n=N$;

        - if Y appears once, by removing it, we are left with two binary (X,Z) string of length $n$ and $N-n-1$, with $0 le n le N-1$.



        b) The string does not contain one (or more) runs of three (or more) consecutive X



        Consider a binary string with $s$ $X; leftrightarrow ,1$'s and $m$ $Z; leftrightarrow ,0$'s in total.

        The number of these strings in which the runs of consecutive ones have a length not greater than $r$, is given by
        $$N_{,b} (s,r,m+1) = text{No}text{. of solutions to};left{ begin{gathered}
        0 leqslant text{integer }x_{,j} leqslant r hfill \
        x_{,1} + x_{,2} + cdots + x_{,m+1} = s hfill \
        end{gathered} right.$$

        which is equal to
        $$
        N_b (s,r,m + 1)quad left| {;0 leqslant text{integers }s,m,r} right.quad
        = sumlimits_{left( {0, leqslant } right),,k,,left( { leqslant ,frac{s}{r}, leqslant ,m + 1} right)}
        {left( { - 1} right)^k left( begin{gathered}
        m + 1 \
        k \
        end{gathered} right)left( begin{gathered}
        s + m - kleft( {r + 1} right) \
        s - kleft( {r + 1} right) \
        end{gathered} right)}
        $$

        as thoroughly explained in this and this other posts.



        In our case $r=2$, and for a string of length $n$ we shall put $m=n-s$ and sum for $0 le s le n$
        $$
        S(n)quad = sumlimits_{left( {0, le } right),s,left( { le ,n} right)} {sumlimits_{left( {0, le } right),,k,,left( { le ,{s over 2},} right)}
        {left( { - 1} right)^k binom{n-s+1}{k} binom{n-3k}{s-3k}
        } }
        $$



        For $n=0,1,2,cdots ,6$ we obtain that $S(n)$ equals
        $$1, 2, 4, 7, 13, 24, 44, cdots$$



        c) Conclusion



        Standing what said in point a) we can conclude that the sought number $T(N)$ is given by
        $$
        T(n) = S(N) + sumlimits_{0, le ,n, le ,N - 1} {S(n),S(N - 1 - n)}
        $$



        For $n=0,1,2,cdots ,8$ $T(n)$ results to be
        $$1, 3, 8, 19, 43, 94, 200, 418, 861, cdots$$
        which checks correctly with a direct count.






        share|cite|improve this answer














        a) Y cannot appear two or more times



        Then

        - if Y does not appear, we are left with a binary (X,Z) string of length $n=N$;

        - if Y appears once, by removing it, we are left with two binary (X,Z) string of length $n$ and $N-n-1$, with $0 le n le N-1$.



        b) The string does not contain one (or more) runs of three (or more) consecutive X



        Consider a binary string with $s$ $X; leftrightarrow ,1$'s and $m$ $Z; leftrightarrow ,0$'s in total.

        The number of these strings in which the runs of consecutive ones have a length not greater than $r$, is given by
        $$N_{,b} (s,r,m+1) = text{No}text{. of solutions to};left{ begin{gathered}
        0 leqslant text{integer }x_{,j} leqslant r hfill \
        x_{,1} + x_{,2} + cdots + x_{,m+1} = s hfill \
        end{gathered} right.$$

        which is equal to
        $$
        N_b (s,r,m + 1)quad left| {;0 leqslant text{integers }s,m,r} right.quad
        = sumlimits_{left( {0, leqslant } right),,k,,left( { leqslant ,frac{s}{r}, leqslant ,m + 1} right)}
        {left( { - 1} right)^k left( begin{gathered}
        m + 1 \
        k \
        end{gathered} right)left( begin{gathered}
        s + m - kleft( {r + 1} right) \
        s - kleft( {r + 1} right) \
        end{gathered} right)}
        $$

        as thoroughly explained in this and this other posts.



        In our case $r=2$, and for a string of length $n$ we shall put $m=n-s$ and sum for $0 le s le n$
        $$
        S(n)quad = sumlimits_{left( {0, le } right),s,left( { le ,n} right)} {sumlimits_{left( {0, le } right),,k,,left( { le ,{s over 2},} right)}
        {left( { - 1} right)^k binom{n-s+1}{k} binom{n-3k}{s-3k}
        } }
        $$



        For $n=0,1,2,cdots ,6$ we obtain that $S(n)$ equals
        $$1, 2, 4, 7, 13, 24, 44, cdots$$



        c) Conclusion



        Standing what said in point a) we can conclude that the sought number $T(N)$ is given by
        $$
        T(n) = S(N) + sumlimits_{0, le ,n, le ,N - 1} {S(n),S(N - 1 - n)}
        $$



        For $n=0,1,2,cdots ,8$ $T(n)$ results to be
        $$1, 3, 8, 19, 43, 94, 200, 418, 861, cdots$$
        which checks correctly with a direct count.







        share|cite|improve this answer














        share|cite|improve this answer



        share|cite|improve this answer








        edited 2 days ago

























        answered 2 days ago









        G Cab

        16.9k31237




        16.9k31237






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2998975%2fwhat-is-the-probability-of-three-consecutive-results-x-and-two-results-y-in-an-e%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