Expected number of coin flips until all cars move to end of array?
Imagine that we have an array of length $2n$, where the first $n$ entries are a $C$ (representing a toy car) and the remaining $n$ entries are empty. Additionally, we have $n$ fair coins labeled $1$ through $n$, where coin $i$ corresponds to car $C_i$ in the array.
On each timestep, we flip all $n$ coins. If coin $i$ comes up as heads, then car $C_i$ moves forward in the array by one spot, but only if it is not blocked by another car directly in the slot in front of it. Else, if blocked or the coin comes up tails, car $C_i$ does nothing.
The question has two parts:
- What is the expected number of timesteps until the $n$-$th$ car reaches the end of the array (reaches slot $2n$)?
- What is the expected number of timesteps until all of the $n$ cars have moved from the first $n$ slots of the array to the last $n$ slots?
I have worked out part 1 as follows. The expected number of flips for one coin to land as heads is $2$, and the $n$-$th$ car has to move $n$ slots to get to the end (and is not blocked by anything ever), so the expected number of timesteps is $2n$. However, I am lost on the approach to part 2. I reason that it should be on the order $O(nlog n$) but do not know how to proceed. I keep running into a long chain of conditional probabilities and wonder if there is a more elegant way I am missing.
probability random-variables expected-value
add a comment |
Imagine that we have an array of length $2n$, where the first $n$ entries are a $C$ (representing a toy car) and the remaining $n$ entries are empty. Additionally, we have $n$ fair coins labeled $1$ through $n$, where coin $i$ corresponds to car $C_i$ in the array.
On each timestep, we flip all $n$ coins. If coin $i$ comes up as heads, then car $C_i$ moves forward in the array by one spot, but only if it is not blocked by another car directly in the slot in front of it. Else, if blocked or the coin comes up tails, car $C_i$ does nothing.
The question has two parts:
- What is the expected number of timesteps until the $n$-$th$ car reaches the end of the array (reaches slot $2n$)?
- What is the expected number of timesteps until all of the $n$ cars have moved from the first $n$ slots of the array to the last $n$ slots?
I have worked out part 1 as follows. The expected number of flips for one coin to land as heads is $2$, and the $n$-$th$ car has to move $n$ slots to get to the end (and is not blocked by anything ever), so the expected number of timesteps is $2n$. However, I am lost on the approach to part 2. I reason that it should be on the order $O(nlog n$) but do not know how to proceed. I keep running into a long chain of conditional probabilities and wonder if there is a more elegant way I am missing.
probability random-variables expected-value
I think it's at least order $n^2$ since that is the amount of time it takes for the 1st car to move even one step
– maridia
Dec 9 '18 at 23:10
See how long it takes for car at $n-1$ to get to its destination and then for car at $n-2$ and see if there is a pattern.
– herb steinberg
Dec 9 '18 at 23:11
@norfair: no, it takes $2n$ for the first car to move once. $n$ takes $2$ flips, then $n-1$ takes $2$ flips, etc. But as car 1 is waiting the front cars are moving farther ahead. I believe it is linear in $n$.
– Ross Millikan
Dec 9 '18 at 23:41
Yes you are right. For some reason, I was summing them up to get the quadratic growth.
– maridia
Dec 9 '18 at 23:56
By the way, I think this is related to the Totally Asymmetric Simple Exclusion Process (or TASEP).
– maridia
Dec 10 '18 at 0:05
add a comment |
Imagine that we have an array of length $2n$, where the first $n$ entries are a $C$ (representing a toy car) and the remaining $n$ entries are empty. Additionally, we have $n$ fair coins labeled $1$ through $n$, where coin $i$ corresponds to car $C_i$ in the array.
On each timestep, we flip all $n$ coins. If coin $i$ comes up as heads, then car $C_i$ moves forward in the array by one spot, but only if it is not blocked by another car directly in the slot in front of it. Else, if blocked or the coin comes up tails, car $C_i$ does nothing.
The question has two parts:
- What is the expected number of timesteps until the $n$-$th$ car reaches the end of the array (reaches slot $2n$)?
- What is the expected number of timesteps until all of the $n$ cars have moved from the first $n$ slots of the array to the last $n$ slots?
I have worked out part 1 as follows. The expected number of flips for one coin to land as heads is $2$, and the $n$-$th$ car has to move $n$ slots to get to the end (and is not blocked by anything ever), so the expected number of timesteps is $2n$. However, I am lost on the approach to part 2. I reason that it should be on the order $O(nlog n$) but do not know how to proceed. I keep running into a long chain of conditional probabilities and wonder if there is a more elegant way I am missing.
probability random-variables expected-value
Imagine that we have an array of length $2n$, where the first $n$ entries are a $C$ (representing a toy car) and the remaining $n$ entries are empty. Additionally, we have $n$ fair coins labeled $1$ through $n$, where coin $i$ corresponds to car $C_i$ in the array.
On each timestep, we flip all $n$ coins. If coin $i$ comes up as heads, then car $C_i$ moves forward in the array by one spot, but only if it is not blocked by another car directly in the slot in front of it. Else, if blocked or the coin comes up tails, car $C_i$ does nothing.
The question has two parts:
- What is the expected number of timesteps until the $n$-$th$ car reaches the end of the array (reaches slot $2n$)?
- What is the expected number of timesteps until all of the $n$ cars have moved from the first $n$ slots of the array to the last $n$ slots?
I have worked out part 1 as follows. The expected number of flips for one coin to land as heads is $2$, and the $n$-$th$ car has to move $n$ slots to get to the end (and is not blocked by anything ever), so the expected number of timesteps is $2n$. However, I am lost on the approach to part 2. I reason that it should be on the order $O(nlog n$) but do not know how to proceed. I keep running into a long chain of conditional probabilities and wonder if there is a more elegant way I am missing.
probability random-variables expected-value
probability random-variables expected-value
asked Dec 9 '18 at 22:57
cashwick
161
161
I think it's at least order $n^2$ since that is the amount of time it takes for the 1st car to move even one step
– maridia
Dec 9 '18 at 23:10
See how long it takes for car at $n-1$ to get to its destination and then for car at $n-2$ and see if there is a pattern.
– herb steinberg
Dec 9 '18 at 23:11
@norfair: no, it takes $2n$ for the first car to move once. $n$ takes $2$ flips, then $n-1$ takes $2$ flips, etc. But as car 1 is waiting the front cars are moving farther ahead. I believe it is linear in $n$.
– Ross Millikan
Dec 9 '18 at 23:41
Yes you are right. For some reason, I was summing them up to get the quadratic growth.
– maridia
Dec 9 '18 at 23:56
By the way, I think this is related to the Totally Asymmetric Simple Exclusion Process (or TASEP).
– maridia
Dec 10 '18 at 0:05
add a comment |
I think it's at least order $n^2$ since that is the amount of time it takes for the 1st car to move even one step
– maridia
Dec 9 '18 at 23:10
See how long it takes for car at $n-1$ to get to its destination and then for car at $n-2$ and see if there is a pattern.
– herb steinberg
Dec 9 '18 at 23:11
@norfair: no, it takes $2n$ for the first car to move once. $n$ takes $2$ flips, then $n-1$ takes $2$ flips, etc. But as car 1 is waiting the front cars are moving farther ahead. I believe it is linear in $n$.
– Ross Millikan
Dec 9 '18 at 23:41
Yes you are right. For some reason, I was summing them up to get the quadratic growth.
– maridia
Dec 9 '18 at 23:56
By the way, I think this is related to the Totally Asymmetric Simple Exclusion Process (or TASEP).
– maridia
Dec 10 '18 at 0:05
I think it's at least order $n^2$ since that is the amount of time it takes for the 1st car to move even one step
– maridia
Dec 9 '18 at 23:10
I think it's at least order $n^2$ since that is the amount of time it takes for the 1st car to move even one step
– maridia
Dec 9 '18 at 23:10
See how long it takes for car at $n-1$ to get to its destination and then for car at $n-2$ and see if there is a pattern.
– herb steinberg
Dec 9 '18 at 23:11
See how long it takes for car at $n-1$ to get to its destination and then for car at $n-2$ and see if there is a pattern.
– herb steinberg
Dec 9 '18 at 23:11
@norfair: no, it takes $2n$ for the first car to move once. $n$ takes $2$ flips, then $n-1$ takes $2$ flips, etc. But as car 1 is waiting the front cars are moving farther ahead. I believe it is linear in $n$.
– Ross Millikan
Dec 9 '18 at 23:41
@norfair: no, it takes $2n$ for the first car to move once. $n$ takes $2$ flips, then $n-1$ takes $2$ flips, etc. But as car 1 is waiting the front cars are moving farther ahead. I believe it is linear in $n$.
– Ross Millikan
Dec 9 '18 at 23:41
Yes you are right. For some reason, I was summing them up to get the quadratic growth.
– maridia
Dec 9 '18 at 23:56
Yes you are right. For some reason, I was summing them up to get the quadratic growth.
– maridia
Dec 9 '18 at 23:56
By the way, I think this is related to the Totally Asymmetric Simple Exclusion Process (or TASEP).
– maridia
Dec 10 '18 at 0:05
By the way, I think this is related to the Totally Asymmetric Simple Exclusion Process (or TASEP).
– maridia
Dec 10 '18 at 0:05
add a comment |
1 Answer
1
active
oldest
votes
I don't have a nice answer for the second part, but we can set bounds. An upper bound is $2n^2$. Imagine we make it harder by saying the $n^{th}$ car has to get to the end before the $n-1^{st}$ car moves at all, then the $n-1^{st}$ has to get to the end before the $n-2^{nd}$ moves at all and so on. By the first part, the expected time for each car is $2n$ so the expected total time is $2n^2$. As cars can only finish faster if they are allowed to move earlier, this is an upper bound.
For the lower bound, let us consider just cars $n$ and $n-1$ and ask the time for $n-1$ to finish. We will make it easier by saying that if $n$ gets two empty spaces between the two cars $n-1$ can move freely without worrying about catching up. Now let $A(k)$ be the expected number of moves when car $n-1$ has $k$ spaces to go and car $n$ is immediately in front of it. Let $B(k)$ be the expected number of moves when car $n-1$ has $k$ spaces to go and car $n$ has $k-1$ spaces to go. We can write coupled recurrences
$$A(k)=1+frac 12B(k)+frac 12A(k)\A(k)=2+B(k)$$
because if the cars are together only car $n$ can move and it moves (putting a space between them) if it gets heads.
$$B(k)=1+frac 14B(k-1)+frac 14(2k)+frac 14A(k-1)+frac 14B(k)$$
because if they both get heads we are in $B(k-1)$, if only the front gets heads it no longer interferes and car $n-1$ will reach the end in $2k$ more moves, if only the rear gets heads we are in $A(k-1)$ and if neither gets heads we stay where we are. The system converges to $A(k)=2k+4$ from below. The time for car $n-2$ must be at least $2n+8$ because the car $n-1$ limits car $n-1$ at least as much as car $n$ limits car $n-1$. This says the time for car $1$ is at least $2n+4(n-1)=6n-4$. I suspect it is not too much worse than this.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3033154%2fexpected-number-of-coin-flips-until-all-cars-move-to-end-of-array%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
I don't have a nice answer for the second part, but we can set bounds. An upper bound is $2n^2$. Imagine we make it harder by saying the $n^{th}$ car has to get to the end before the $n-1^{st}$ car moves at all, then the $n-1^{st}$ has to get to the end before the $n-2^{nd}$ moves at all and so on. By the first part, the expected time for each car is $2n$ so the expected total time is $2n^2$. As cars can only finish faster if they are allowed to move earlier, this is an upper bound.
For the lower bound, let us consider just cars $n$ and $n-1$ and ask the time for $n-1$ to finish. We will make it easier by saying that if $n$ gets two empty spaces between the two cars $n-1$ can move freely without worrying about catching up. Now let $A(k)$ be the expected number of moves when car $n-1$ has $k$ spaces to go and car $n$ is immediately in front of it. Let $B(k)$ be the expected number of moves when car $n-1$ has $k$ spaces to go and car $n$ has $k-1$ spaces to go. We can write coupled recurrences
$$A(k)=1+frac 12B(k)+frac 12A(k)\A(k)=2+B(k)$$
because if the cars are together only car $n$ can move and it moves (putting a space between them) if it gets heads.
$$B(k)=1+frac 14B(k-1)+frac 14(2k)+frac 14A(k-1)+frac 14B(k)$$
because if they both get heads we are in $B(k-1)$, if only the front gets heads it no longer interferes and car $n-1$ will reach the end in $2k$ more moves, if only the rear gets heads we are in $A(k-1)$ and if neither gets heads we stay where we are. The system converges to $A(k)=2k+4$ from below. The time for car $n-2$ must be at least $2n+8$ because the car $n-1$ limits car $n-1$ at least as much as car $n$ limits car $n-1$. This says the time for car $1$ is at least $2n+4(n-1)=6n-4$. I suspect it is not too much worse than this.
add a comment |
I don't have a nice answer for the second part, but we can set bounds. An upper bound is $2n^2$. Imagine we make it harder by saying the $n^{th}$ car has to get to the end before the $n-1^{st}$ car moves at all, then the $n-1^{st}$ has to get to the end before the $n-2^{nd}$ moves at all and so on. By the first part, the expected time for each car is $2n$ so the expected total time is $2n^2$. As cars can only finish faster if they are allowed to move earlier, this is an upper bound.
For the lower bound, let us consider just cars $n$ and $n-1$ and ask the time for $n-1$ to finish. We will make it easier by saying that if $n$ gets two empty spaces between the two cars $n-1$ can move freely without worrying about catching up. Now let $A(k)$ be the expected number of moves when car $n-1$ has $k$ spaces to go and car $n$ is immediately in front of it. Let $B(k)$ be the expected number of moves when car $n-1$ has $k$ spaces to go and car $n$ has $k-1$ spaces to go. We can write coupled recurrences
$$A(k)=1+frac 12B(k)+frac 12A(k)\A(k)=2+B(k)$$
because if the cars are together only car $n$ can move and it moves (putting a space between them) if it gets heads.
$$B(k)=1+frac 14B(k-1)+frac 14(2k)+frac 14A(k-1)+frac 14B(k)$$
because if they both get heads we are in $B(k-1)$, if only the front gets heads it no longer interferes and car $n-1$ will reach the end in $2k$ more moves, if only the rear gets heads we are in $A(k-1)$ and if neither gets heads we stay where we are. The system converges to $A(k)=2k+4$ from below. The time for car $n-2$ must be at least $2n+8$ because the car $n-1$ limits car $n-1$ at least as much as car $n$ limits car $n-1$. This says the time for car $1$ is at least $2n+4(n-1)=6n-4$. I suspect it is not too much worse than this.
add a comment |
I don't have a nice answer for the second part, but we can set bounds. An upper bound is $2n^2$. Imagine we make it harder by saying the $n^{th}$ car has to get to the end before the $n-1^{st}$ car moves at all, then the $n-1^{st}$ has to get to the end before the $n-2^{nd}$ moves at all and so on. By the first part, the expected time for each car is $2n$ so the expected total time is $2n^2$. As cars can only finish faster if they are allowed to move earlier, this is an upper bound.
For the lower bound, let us consider just cars $n$ and $n-1$ and ask the time for $n-1$ to finish. We will make it easier by saying that if $n$ gets two empty spaces between the two cars $n-1$ can move freely without worrying about catching up. Now let $A(k)$ be the expected number of moves when car $n-1$ has $k$ spaces to go and car $n$ is immediately in front of it. Let $B(k)$ be the expected number of moves when car $n-1$ has $k$ spaces to go and car $n$ has $k-1$ spaces to go. We can write coupled recurrences
$$A(k)=1+frac 12B(k)+frac 12A(k)\A(k)=2+B(k)$$
because if the cars are together only car $n$ can move and it moves (putting a space between them) if it gets heads.
$$B(k)=1+frac 14B(k-1)+frac 14(2k)+frac 14A(k-1)+frac 14B(k)$$
because if they both get heads we are in $B(k-1)$, if only the front gets heads it no longer interferes and car $n-1$ will reach the end in $2k$ more moves, if only the rear gets heads we are in $A(k-1)$ and if neither gets heads we stay where we are. The system converges to $A(k)=2k+4$ from below. The time for car $n-2$ must be at least $2n+8$ because the car $n-1$ limits car $n-1$ at least as much as car $n$ limits car $n-1$. This says the time for car $1$ is at least $2n+4(n-1)=6n-4$. I suspect it is not too much worse than this.
I don't have a nice answer for the second part, but we can set bounds. An upper bound is $2n^2$. Imagine we make it harder by saying the $n^{th}$ car has to get to the end before the $n-1^{st}$ car moves at all, then the $n-1^{st}$ has to get to the end before the $n-2^{nd}$ moves at all and so on. By the first part, the expected time for each car is $2n$ so the expected total time is $2n^2$. As cars can only finish faster if they are allowed to move earlier, this is an upper bound.
For the lower bound, let us consider just cars $n$ and $n-1$ and ask the time for $n-1$ to finish. We will make it easier by saying that if $n$ gets two empty spaces between the two cars $n-1$ can move freely without worrying about catching up. Now let $A(k)$ be the expected number of moves when car $n-1$ has $k$ spaces to go and car $n$ is immediately in front of it. Let $B(k)$ be the expected number of moves when car $n-1$ has $k$ spaces to go and car $n$ has $k-1$ spaces to go. We can write coupled recurrences
$$A(k)=1+frac 12B(k)+frac 12A(k)\A(k)=2+B(k)$$
because if the cars are together only car $n$ can move and it moves (putting a space between them) if it gets heads.
$$B(k)=1+frac 14B(k-1)+frac 14(2k)+frac 14A(k-1)+frac 14B(k)$$
because if they both get heads we are in $B(k-1)$, if only the front gets heads it no longer interferes and car $n-1$ will reach the end in $2k$ more moves, if only the rear gets heads we are in $A(k-1)$ and if neither gets heads we stay where we are. The system converges to $A(k)=2k+4$ from below. The time for car $n-2$ must be at least $2n+8$ because the car $n-1$ limits car $n-1$ at least as much as car $n$ limits car $n-1$. This says the time for car $1$ is at least $2n+4(n-1)=6n-4$. I suspect it is not too much worse than this.
answered Dec 9 '18 at 23:39
Ross Millikan
292k23196371
292k23196371
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3033154%2fexpected-number-of-coin-flips-until-all-cars-move-to-end-of-array%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
I think it's at least order $n^2$ since that is the amount of time it takes for the 1st car to move even one step
– maridia
Dec 9 '18 at 23:10
See how long it takes for car at $n-1$ to get to its destination and then for car at $n-2$ and see if there is a pattern.
– herb steinberg
Dec 9 '18 at 23:11
@norfair: no, it takes $2n$ for the first car to move once. $n$ takes $2$ flips, then $n-1$ takes $2$ flips, etc. But as car 1 is waiting the front cars are moving farther ahead. I believe it is linear in $n$.
– Ross Millikan
Dec 9 '18 at 23:41
Yes you are right. For some reason, I was summing them up to get the quadratic growth.
– maridia
Dec 9 '18 at 23:56
By the way, I think this is related to the Totally Asymmetric Simple Exclusion Process (or TASEP).
– maridia
Dec 10 '18 at 0:05