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
























  • 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






  • 1




    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
    Nov 21 at 18:23






  • 1




    would like to know your feedback to my answer
    – G Cab
    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
























  • 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






  • 1




    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
    Nov 21 at 18:23






  • 1




    would like to know your feedback to my answer
    – G Cab
    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 Nov 21 at 19:02

























asked Nov 14 at 23:40









user3026388

9810




9810












  • 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






  • 1




    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
    Nov 21 at 18:23






  • 1




    would like to know your feedback to my answer
    – G Cab
    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






  • 1




    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
    Nov 21 at 18:23






  • 1




    would like to know your feedback to my answer
    – G Cab
    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




1




1




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
Nov 21 at 18:23




Do you mean Y happens exactly twice or at least twice?
– Mostafa Ayaz
Nov 21 at 18:23




1




1




would like to know your feedback to my answer
– G Cab
2 days ago




would like to know your feedback to my answer
– G Cab
2 days ago










1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










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























  • Thank you, I get it now! I appreciate it
    – user3026388
    2 days ago










  • glad it is useful, if you need any explanation just ask
    – G Cab
    2 days ago











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
2
down vote



accepted










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























  • Thank you, I get it now! I appreciate it
    – user3026388
    2 days ago










  • glad it is useful, if you need any explanation just ask
    – G Cab
    2 days ago















up vote
2
down vote



accepted










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























  • Thank you, I get it now! I appreciate it
    – user3026388
    2 days ago










  • glad it is useful, if you need any explanation just ask
    – G Cab
    2 days ago













up vote
2
down vote



accepted







up vote
2
down vote



accepted






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 Nov 22 at 0:54

























answered Nov 22 at 0:38









G Cab

17.1k31237




17.1k31237












  • Thank you, I get it now! I appreciate it
    – user3026388
    2 days ago










  • glad it is useful, if you need any explanation just ask
    – G Cab
    2 days ago


















  • Thank you, I get it now! I appreciate it
    – user3026388
    2 days ago










  • glad it is useful, if you need any explanation just ask
    – G Cab
    2 days ago
















Thank you, I get it now! I appreciate it
– user3026388
2 days ago




Thank you, I get it now! I appreciate it
– user3026388
2 days ago












glad it is useful, if you need any explanation just ask
– G Cab
2 days ago




glad it is useful, if you need any explanation just ask
– G Cab
2 days ago


















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%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

Bundesstraße 106

Le Mesnil-Réaume

Ida-Boy-Ed-Garten