Sisyphus Random Walk
$begingroup$
A Sisyphus Random Walk evolves as follows: With probability (r) you advance the position of the walker by +1. With probability (1-r) the walker resets at x0 = 0.
To simulate the probability of reset I use a Bernoulli Distribution:
t = Prepend[RandomVariate[BernoulliDistribution[0.7], 9],0]
{0, 1, 1, 0, 1, 0, 1, 1, 1, 1}
According to this distribution the walk should evolve as follows:
srw = {0,1,2,0,1,0,1,2,3,4}
I am unsure what functions I should use to get the desired output.
functions programming probability-or-statistics random distributions
$endgroup$
add a comment |
$begingroup$
A Sisyphus Random Walk evolves as follows: With probability (r) you advance the position of the walker by +1. With probability (1-r) the walker resets at x0 = 0.
To simulate the probability of reset I use a Bernoulli Distribution:
t = Prepend[RandomVariate[BernoulliDistribution[0.7], 9],0]
{0, 1, 1, 0, 1, 0, 1, 1, 1, 1}
According to this distribution the walk should evolve as follows:
srw = {0,1,2,0,1,0,1,2,3,4}
I am unsure what functions I should use to get the desired output.
functions programming probability-or-statistics random distributions
$endgroup$
$begingroup$
closely related: Faster “stuttering” accumulate
$endgroup$
– kglr
5 hours ago
add a comment |
$begingroup$
A Sisyphus Random Walk evolves as follows: With probability (r) you advance the position of the walker by +1. With probability (1-r) the walker resets at x0 = 0.
To simulate the probability of reset I use a Bernoulli Distribution:
t = Prepend[RandomVariate[BernoulliDistribution[0.7], 9],0]
{0, 1, 1, 0, 1, 0, 1, 1, 1, 1}
According to this distribution the walk should evolve as follows:
srw = {0,1,2,0,1,0,1,2,3,4}
I am unsure what functions I should use to get the desired output.
functions programming probability-or-statistics random distributions
$endgroup$
A Sisyphus Random Walk evolves as follows: With probability (r) you advance the position of the walker by +1. With probability (1-r) the walker resets at x0 = 0.
To simulate the probability of reset I use a Bernoulli Distribution:
t = Prepend[RandomVariate[BernoulliDistribution[0.7], 9],0]
{0, 1, 1, 0, 1, 0, 1, 1, 1, 1}
According to this distribution the walk should evolve as follows:
srw = {0,1,2,0,1,0,1,2,3,4}
I am unsure what functions I should use to get the desired output.
functions programming probability-or-statistics random distributions
functions programming probability-or-statistics random distributions
asked 16 hours ago
WillWill
1825
1825
$begingroup$
closely related: Faster “stuttering” accumulate
$endgroup$
– kglr
5 hours ago
add a comment |
$begingroup$
closely related: Faster “stuttering” accumulate
$endgroup$
– kglr
5 hours ago
$begingroup$
closely related: Faster “stuttering” accumulate
$endgroup$
– kglr
5 hours ago
$begingroup$
closely related: Faster “stuttering” accumulate
$endgroup$
– kglr
5 hours ago
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
We can iterate with FoldList
:
data = {0, 1, 1, 0, 1, 0, 1, 1, 1, 1};
FoldList[#2 * (#1 + #2)&, data]
{0, 1, 2, 0, 1, 0, 1, 2, 3, 4}
Another approach is to accumulate consecutive runs of 1
:
Join @@ Accumulate /@ Split[data]
{0, 1, 2, 0, 1, 0, 1, 2, 3, 4}
$endgroup$
add a comment |
$begingroup$
WARNING sorry, an error in this solution was just pointed out to me by another user. I am busy doing the necessary corrections.
A nice problem. Why not solve it analytically?
Let us use Latex to formulate the problem and write down the solution, and then move to Mathematica. Finally we discuss the results and generalizations.
Part 1: mathematical formulation of the problem
Let $w(t,k)$ be the probability that at time t(>=0) the walker is at position k.
Then let us derive the evolution equations. We do it carefully now because previously I had made an error here.
For $k>0$ we have the balance
$$w(t+1,k) = w(t,k) text{(old value)} - r w(t,k) text{(loss to k+1)}$$
$$+ r w(t,k-1) text{(gain from k-1)}-(1-r)w(t,k) text{(loss to 0)}$$
this gives the equation
$$w(t+1,k) = r; w(t,k-1), ;;;;;tge0, kgt0tag{1}$$
For $k=0$ we have
$$w(t+1,0) = w(t,0)text{(old value)}- r w(t,0)text{(loss to 1)} + (1-r) left(w(t,1)+w(t,2)+...right)text{(gain from all others)}$$
This gives
$$w(t+1,0) = (1-r) sum_{k=0}^infty w(t,k)$$
which greatly simplifies to the simple equation
$$w(t+1,0) = (1-r)tag{2}$$
Indeed, since at any time $tge0$ the walker must be at one of the locations $kge 0$ with certainty we must have
$sum_{k=0}^infty w(t,k)=1$.
In order to finalize the formulation of the problem we need initial conditions.
We assume that the walker at $t=0$ is in location $k=nge0$, i.e.
$$w(0,k)=delta_{k,n}tag{3}$$
where $delta_{k,n}$ is the Kronecker symbol defined as unity if $k=n$ and $0$ otherwise.
Part 2: solution with Mathematica
First we calculate w[t,0]
.
No calculation is necessary because (2) already gives the solution whih is constant for $tgt0$.
This result is independent of the specifiy starting point of the walker: if he would start at $k=0$ then, for t=1 he jumps to $k=1$ with probability $r$ which means that he remains at $k=0$ with probability $1-r$. If he starts at any other location he jumps back to $0$ in the next tmes step with probability $(1-r)$, hence we obtain the same result.
Now we turn to positions k>0.
(still to be checked)
From (1) we have
sol = RSolve[w[t + 1, k] == r w[t, k - 1], w[t, k], {t, k}]
(* Out[43]= {{w[t, k] -> r^(-1 + t) C[1][k - t]}} *)
Don't worry about the strange looking expression of the constant C[1]
with an argument. This is exactly what we need to apply the initial condition (5).
Defining the auxiliary function
vc[t_, k_] = w[t, k] /. sol[[1]] t_, k]
(* Out[41]= r^(-1 + t) C[1][k - t] *)
condition (5) reads
sol1 = Solve[vc[0, k] == KroneckerDelta[k, n], C[1][k]]
(* Out[43]= {{C[1][k] -> r KroneckerDelta[k, n]}} *)
Hence the probability for the walker to be at location k at time t if he started at location n>0 (with the basic probability r of jumping one step to the the right) is given by
w[t_, k_, r_, n_] = r^t KroneckerDelta[k - t, n]
(* Out[50]= r^t KroneckerDelta[n, k - t] *)
Example 1:
n=1, r=1/2, w(t,k) is only different from 0 if k=t+1.
The first few values of these non vanishing Terms are
With[{n = 1, r = 1/2}, Table[w[t, t + 1, r, n], {t, 0, 10}]]
(* Out[58]= {1, 1/2, 1/4, 1/8, 1/16, 1/32, 1/64, 1/128, 1/256, 1/512, 1/1024} *)
The complete probabilities form a two dimensional array, which might start like this
With[{n = 3, r = 1/2},
tt = Table[w[t, k, r, n], {t, 0, 5}, {k, 1, 10}]]
(* Out[133]= {{0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 1/2, 0, 0, 0, 0,
0, 0}, {0, 0, 0, 0, 1/4, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 1/8, 0, 0,
0, 0}, {0, 0, 0, 0, 0, 0, 1/16, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 1/
32, 0, 0}} *)
Visualization
ListPlot3D[tt,
PlotLabel ->
"Sysiphos random walk for r=1/2 starting at k=3nProbability w(t,k)
for k>0 as a function of time", PlotRange -> {-0.1, 1},
AxesLabel -> {"k", "t", "w(t,k)"}]
Part 3: discussion
Asymptotic behaviour for large times
The probabilities (6) and (7) at the origin approache a common value
$$w(ttoinfty,0) = frac{1-r}{2-r}tag{9}$$
As the walker must be initially either at the origin or not ("at home or out") the asymptotic value (9) holds for any initial state.
This means that the walker has asymptotically "gone out" with probability
$$w'(ttoinfty,0) = 1- w(ttoinfty,0) = frac{1}{2-r}$$
If the jump probability $r$ is small, it becomes equally probable that the walker is at home or out.
If $rto 1$ the walker is almost certainly out.
Next question: what is the asymptotic shape of the spatial profile? That is what is $w(ttoinfty,k)$ as a function of $k$?
My feeling tells me that is should be exponential ... like the pressure in the atmosphere.
Let's look at it qualitatively: if there were no jumping back, the walker would move away to $ktoinfty$ indefinitely. The jumping back leads to renewed filling from below of, in principle, any position.
What about $w(t,1)$? Let us try to calculate it exactly.
$endgroup$
$begingroup$
Something seems wrong to me. After one time step, the probability to be at the origin (k=0) is 1/2. After a second time step, half of that amount (0.25) is at k=1. That large a probability should be visible on the graph. What am I missing? And could you include k=0 in the above plot?
$endgroup$
– Kieran Mullen
8 hours ago
$begingroup$
@Kieran Mullen Ooops, I'll check it.
$endgroup$
– Dr. Wolfgang Hintze
8 hours ago
$begingroup$
@Kieran Mullen: you are right, I was wrong. Thanks a lot for pointing this out. Thinking more thouroughly I find for a walker starting at $k=0$ that $w(t<k)=0$, $w(t=k) = 1/2^k$, and $w(t>k)=1/2^{k+1}$. Hence the asymptotic profile is indeed exponential. Need to revise my work, not sure which part of it I can save.
$endgroup$
– Dr. Wolfgang Hintze
7 hours ago
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: "387"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
},
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%2fmathematica.stackexchange.com%2fquestions%2f189764%2fsisyphus-random-walk%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
$begingroup$
We can iterate with FoldList
:
data = {0, 1, 1, 0, 1, 0, 1, 1, 1, 1};
FoldList[#2 * (#1 + #2)&, data]
{0, 1, 2, 0, 1, 0, 1, 2, 3, 4}
Another approach is to accumulate consecutive runs of 1
:
Join @@ Accumulate /@ Split[data]
{0, 1, 2, 0, 1, 0, 1, 2, 3, 4}
$endgroup$
add a comment |
$begingroup$
We can iterate with FoldList
:
data = {0, 1, 1, 0, 1, 0, 1, 1, 1, 1};
FoldList[#2 * (#1 + #2)&, data]
{0, 1, 2, 0, 1, 0, 1, 2, 3, 4}
Another approach is to accumulate consecutive runs of 1
:
Join @@ Accumulate /@ Split[data]
{0, 1, 2, 0, 1, 0, 1, 2, 3, 4}
$endgroup$
add a comment |
$begingroup$
We can iterate with FoldList
:
data = {0, 1, 1, 0, 1, 0, 1, 1, 1, 1};
FoldList[#2 * (#1 + #2)&, data]
{0, 1, 2, 0, 1, 0, 1, 2, 3, 4}
Another approach is to accumulate consecutive runs of 1
:
Join @@ Accumulate /@ Split[data]
{0, 1, 2, 0, 1, 0, 1, 2, 3, 4}
$endgroup$
We can iterate with FoldList
:
data = {0, 1, 1, 0, 1, 0, 1, 1, 1, 1};
FoldList[#2 * (#1 + #2)&, data]
{0, 1, 2, 0, 1, 0, 1, 2, 3, 4}
Another approach is to accumulate consecutive runs of 1
:
Join @@ Accumulate /@ Split[data]
{0, 1, 2, 0, 1, 0, 1, 2, 3, 4}
answered 15 hours ago
Chip HurstChip Hurst
20.5k15787
20.5k15787
add a comment |
add a comment |
$begingroup$
WARNING sorry, an error in this solution was just pointed out to me by another user. I am busy doing the necessary corrections.
A nice problem. Why not solve it analytically?
Let us use Latex to formulate the problem and write down the solution, and then move to Mathematica. Finally we discuss the results and generalizations.
Part 1: mathematical formulation of the problem
Let $w(t,k)$ be the probability that at time t(>=0) the walker is at position k.
Then let us derive the evolution equations. We do it carefully now because previously I had made an error here.
For $k>0$ we have the balance
$$w(t+1,k) = w(t,k) text{(old value)} - r w(t,k) text{(loss to k+1)}$$
$$+ r w(t,k-1) text{(gain from k-1)}-(1-r)w(t,k) text{(loss to 0)}$$
this gives the equation
$$w(t+1,k) = r; w(t,k-1), ;;;;;tge0, kgt0tag{1}$$
For $k=0$ we have
$$w(t+1,0) = w(t,0)text{(old value)}- r w(t,0)text{(loss to 1)} + (1-r) left(w(t,1)+w(t,2)+...right)text{(gain from all others)}$$
This gives
$$w(t+1,0) = (1-r) sum_{k=0}^infty w(t,k)$$
which greatly simplifies to the simple equation
$$w(t+1,0) = (1-r)tag{2}$$
Indeed, since at any time $tge0$ the walker must be at one of the locations $kge 0$ with certainty we must have
$sum_{k=0}^infty w(t,k)=1$.
In order to finalize the formulation of the problem we need initial conditions.
We assume that the walker at $t=0$ is in location $k=nge0$, i.e.
$$w(0,k)=delta_{k,n}tag{3}$$
where $delta_{k,n}$ is the Kronecker symbol defined as unity if $k=n$ and $0$ otherwise.
Part 2: solution with Mathematica
First we calculate w[t,0]
.
No calculation is necessary because (2) already gives the solution whih is constant for $tgt0$.
This result is independent of the specifiy starting point of the walker: if he would start at $k=0$ then, for t=1 he jumps to $k=1$ with probability $r$ which means that he remains at $k=0$ with probability $1-r$. If he starts at any other location he jumps back to $0$ in the next tmes step with probability $(1-r)$, hence we obtain the same result.
Now we turn to positions k>0.
(still to be checked)
From (1) we have
sol = RSolve[w[t + 1, k] == r w[t, k - 1], w[t, k], {t, k}]
(* Out[43]= {{w[t, k] -> r^(-1 + t) C[1][k - t]}} *)
Don't worry about the strange looking expression of the constant C[1]
with an argument. This is exactly what we need to apply the initial condition (5).
Defining the auxiliary function
vc[t_, k_] = w[t, k] /. sol[[1]] t_, k]
(* Out[41]= r^(-1 + t) C[1][k - t] *)
condition (5) reads
sol1 = Solve[vc[0, k] == KroneckerDelta[k, n], C[1][k]]
(* Out[43]= {{C[1][k] -> r KroneckerDelta[k, n]}} *)
Hence the probability for the walker to be at location k at time t if he started at location n>0 (with the basic probability r of jumping one step to the the right) is given by
w[t_, k_, r_, n_] = r^t KroneckerDelta[k - t, n]
(* Out[50]= r^t KroneckerDelta[n, k - t] *)
Example 1:
n=1, r=1/2, w(t,k) is only different from 0 if k=t+1.
The first few values of these non vanishing Terms are
With[{n = 1, r = 1/2}, Table[w[t, t + 1, r, n], {t, 0, 10}]]
(* Out[58]= {1, 1/2, 1/4, 1/8, 1/16, 1/32, 1/64, 1/128, 1/256, 1/512, 1/1024} *)
The complete probabilities form a two dimensional array, which might start like this
With[{n = 3, r = 1/2},
tt = Table[w[t, k, r, n], {t, 0, 5}, {k, 1, 10}]]
(* Out[133]= {{0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 1/2, 0, 0, 0, 0,
0, 0}, {0, 0, 0, 0, 1/4, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 1/8, 0, 0,
0, 0}, {0, 0, 0, 0, 0, 0, 1/16, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 1/
32, 0, 0}} *)
Visualization
ListPlot3D[tt,
PlotLabel ->
"Sysiphos random walk for r=1/2 starting at k=3nProbability w(t,k)
for k>0 as a function of time", PlotRange -> {-0.1, 1},
AxesLabel -> {"k", "t", "w(t,k)"}]
Part 3: discussion
Asymptotic behaviour for large times
The probabilities (6) and (7) at the origin approache a common value
$$w(ttoinfty,0) = frac{1-r}{2-r}tag{9}$$
As the walker must be initially either at the origin or not ("at home or out") the asymptotic value (9) holds for any initial state.
This means that the walker has asymptotically "gone out" with probability
$$w'(ttoinfty,0) = 1- w(ttoinfty,0) = frac{1}{2-r}$$
If the jump probability $r$ is small, it becomes equally probable that the walker is at home or out.
If $rto 1$ the walker is almost certainly out.
Next question: what is the asymptotic shape of the spatial profile? That is what is $w(ttoinfty,k)$ as a function of $k$?
My feeling tells me that is should be exponential ... like the pressure in the atmosphere.
Let's look at it qualitatively: if there were no jumping back, the walker would move away to $ktoinfty$ indefinitely. The jumping back leads to renewed filling from below of, in principle, any position.
What about $w(t,1)$? Let us try to calculate it exactly.
$endgroup$
$begingroup$
Something seems wrong to me. After one time step, the probability to be at the origin (k=0) is 1/2. After a second time step, half of that amount (0.25) is at k=1. That large a probability should be visible on the graph. What am I missing? And could you include k=0 in the above plot?
$endgroup$
– Kieran Mullen
8 hours ago
$begingroup$
@Kieran Mullen Ooops, I'll check it.
$endgroup$
– Dr. Wolfgang Hintze
8 hours ago
$begingroup$
@Kieran Mullen: you are right, I was wrong. Thanks a lot for pointing this out. Thinking more thouroughly I find for a walker starting at $k=0$ that $w(t<k)=0$, $w(t=k) = 1/2^k$, and $w(t>k)=1/2^{k+1}$. Hence the asymptotic profile is indeed exponential. Need to revise my work, not sure which part of it I can save.
$endgroup$
– Dr. Wolfgang Hintze
7 hours ago
add a comment |
$begingroup$
WARNING sorry, an error in this solution was just pointed out to me by another user. I am busy doing the necessary corrections.
A nice problem. Why not solve it analytically?
Let us use Latex to formulate the problem and write down the solution, and then move to Mathematica. Finally we discuss the results and generalizations.
Part 1: mathematical formulation of the problem
Let $w(t,k)$ be the probability that at time t(>=0) the walker is at position k.
Then let us derive the evolution equations. We do it carefully now because previously I had made an error here.
For $k>0$ we have the balance
$$w(t+1,k) = w(t,k) text{(old value)} - r w(t,k) text{(loss to k+1)}$$
$$+ r w(t,k-1) text{(gain from k-1)}-(1-r)w(t,k) text{(loss to 0)}$$
this gives the equation
$$w(t+1,k) = r; w(t,k-1), ;;;;;tge0, kgt0tag{1}$$
For $k=0$ we have
$$w(t+1,0) = w(t,0)text{(old value)}- r w(t,0)text{(loss to 1)} + (1-r) left(w(t,1)+w(t,2)+...right)text{(gain from all others)}$$
This gives
$$w(t+1,0) = (1-r) sum_{k=0}^infty w(t,k)$$
which greatly simplifies to the simple equation
$$w(t+1,0) = (1-r)tag{2}$$
Indeed, since at any time $tge0$ the walker must be at one of the locations $kge 0$ with certainty we must have
$sum_{k=0}^infty w(t,k)=1$.
In order to finalize the formulation of the problem we need initial conditions.
We assume that the walker at $t=0$ is in location $k=nge0$, i.e.
$$w(0,k)=delta_{k,n}tag{3}$$
where $delta_{k,n}$ is the Kronecker symbol defined as unity if $k=n$ and $0$ otherwise.
Part 2: solution with Mathematica
First we calculate w[t,0]
.
No calculation is necessary because (2) already gives the solution whih is constant for $tgt0$.
This result is independent of the specifiy starting point of the walker: if he would start at $k=0$ then, for t=1 he jumps to $k=1$ with probability $r$ which means that he remains at $k=0$ with probability $1-r$. If he starts at any other location he jumps back to $0$ in the next tmes step with probability $(1-r)$, hence we obtain the same result.
Now we turn to positions k>0.
(still to be checked)
From (1) we have
sol = RSolve[w[t + 1, k] == r w[t, k - 1], w[t, k], {t, k}]
(* Out[43]= {{w[t, k] -> r^(-1 + t) C[1][k - t]}} *)
Don't worry about the strange looking expression of the constant C[1]
with an argument. This is exactly what we need to apply the initial condition (5).
Defining the auxiliary function
vc[t_, k_] = w[t, k] /. sol[[1]] t_, k]
(* Out[41]= r^(-1 + t) C[1][k - t] *)
condition (5) reads
sol1 = Solve[vc[0, k] == KroneckerDelta[k, n], C[1][k]]
(* Out[43]= {{C[1][k] -> r KroneckerDelta[k, n]}} *)
Hence the probability for the walker to be at location k at time t if he started at location n>0 (with the basic probability r of jumping one step to the the right) is given by
w[t_, k_, r_, n_] = r^t KroneckerDelta[k - t, n]
(* Out[50]= r^t KroneckerDelta[n, k - t] *)
Example 1:
n=1, r=1/2, w(t,k) is only different from 0 if k=t+1.
The first few values of these non vanishing Terms are
With[{n = 1, r = 1/2}, Table[w[t, t + 1, r, n], {t, 0, 10}]]
(* Out[58]= {1, 1/2, 1/4, 1/8, 1/16, 1/32, 1/64, 1/128, 1/256, 1/512, 1/1024} *)
The complete probabilities form a two dimensional array, which might start like this
With[{n = 3, r = 1/2},
tt = Table[w[t, k, r, n], {t, 0, 5}, {k, 1, 10}]]
(* Out[133]= {{0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 1/2, 0, 0, 0, 0,
0, 0}, {0, 0, 0, 0, 1/4, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 1/8, 0, 0,
0, 0}, {0, 0, 0, 0, 0, 0, 1/16, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 1/
32, 0, 0}} *)
Visualization
ListPlot3D[tt,
PlotLabel ->
"Sysiphos random walk for r=1/2 starting at k=3nProbability w(t,k)
for k>0 as a function of time", PlotRange -> {-0.1, 1},
AxesLabel -> {"k", "t", "w(t,k)"}]
Part 3: discussion
Asymptotic behaviour for large times
The probabilities (6) and (7) at the origin approache a common value
$$w(ttoinfty,0) = frac{1-r}{2-r}tag{9}$$
As the walker must be initially either at the origin or not ("at home or out") the asymptotic value (9) holds for any initial state.
This means that the walker has asymptotically "gone out" with probability
$$w'(ttoinfty,0) = 1- w(ttoinfty,0) = frac{1}{2-r}$$
If the jump probability $r$ is small, it becomes equally probable that the walker is at home or out.
If $rto 1$ the walker is almost certainly out.
Next question: what is the asymptotic shape of the spatial profile? That is what is $w(ttoinfty,k)$ as a function of $k$?
My feeling tells me that is should be exponential ... like the pressure in the atmosphere.
Let's look at it qualitatively: if there were no jumping back, the walker would move away to $ktoinfty$ indefinitely. The jumping back leads to renewed filling from below of, in principle, any position.
What about $w(t,1)$? Let us try to calculate it exactly.
$endgroup$
$begingroup$
Something seems wrong to me. After one time step, the probability to be at the origin (k=0) is 1/2. After a second time step, half of that amount (0.25) is at k=1. That large a probability should be visible on the graph. What am I missing? And could you include k=0 in the above plot?
$endgroup$
– Kieran Mullen
8 hours ago
$begingroup$
@Kieran Mullen Ooops, I'll check it.
$endgroup$
– Dr. Wolfgang Hintze
8 hours ago
$begingroup$
@Kieran Mullen: you are right, I was wrong. Thanks a lot for pointing this out. Thinking more thouroughly I find for a walker starting at $k=0$ that $w(t<k)=0$, $w(t=k) = 1/2^k$, and $w(t>k)=1/2^{k+1}$. Hence the asymptotic profile is indeed exponential. Need to revise my work, not sure which part of it I can save.
$endgroup$
– Dr. Wolfgang Hintze
7 hours ago
add a comment |
$begingroup$
WARNING sorry, an error in this solution was just pointed out to me by another user. I am busy doing the necessary corrections.
A nice problem. Why not solve it analytically?
Let us use Latex to formulate the problem and write down the solution, and then move to Mathematica. Finally we discuss the results and generalizations.
Part 1: mathematical formulation of the problem
Let $w(t,k)$ be the probability that at time t(>=0) the walker is at position k.
Then let us derive the evolution equations. We do it carefully now because previously I had made an error here.
For $k>0$ we have the balance
$$w(t+1,k) = w(t,k) text{(old value)} - r w(t,k) text{(loss to k+1)}$$
$$+ r w(t,k-1) text{(gain from k-1)}-(1-r)w(t,k) text{(loss to 0)}$$
this gives the equation
$$w(t+1,k) = r; w(t,k-1), ;;;;;tge0, kgt0tag{1}$$
For $k=0$ we have
$$w(t+1,0) = w(t,0)text{(old value)}- r w(t,0)text{(loss to 1)} + (1-r) left(w(t,1)+w(t,2)+...right)text{(gain from all others)}$$
This gives
$$w(t+1,0) = (1-r) sum_{k=0}^infty w(t,k)$$
which greatly simplifies to the simple equation
$$w(t+1,0) = (1-r)tag{2}$$
Indeed, since at any time $tge0$ the walker must be at one of the locations $kge 0$ with certainty we must have
$sum_{k=0}^infty w(t,k)=1$.
In order to finalize the formulation of the problem we need initial conditions.
We assume that the walker at $t=0$ is in location $k=nge0$, i.e.
$$w(0,k)=delta_{k,n}tag{3}$$
where $delta_{k,n}$ is the Kronecker symbol defined as unity if $k=n$ and $0$ otherwise.
Part 2: solution with Mathematica
First we calculate w[t,0]
.
No calculation is necessary because (2) already gives the solution whih is constant for $tgt0$.
This result is independent of the specifiy starting point of the walker: if he would start at $k=0$ then, for t=1 he jumps to $k=1$ with probability $r$ which means that he remains at $k=0$ with probability $1-r$. If he starts at any other location he jumps back to $0$ in the next tmes step with probability $(1-r)$, hence we obtain the same result.
Now we turn to positions k>0.
(still to be checked)
From (1) we have
sol = RSolve[w[t + 1, k] == r w[t, k - 1], w[t, k], {t, k}]
(* Out[43]= {{w[t, k] -> r^(-1 + t) C[1][k - t]}} *)
Don't worry about the strange looking expression of the constant C[1]
with an argument. This is exactly what we need to apply the initial condition (5).
Defining the auxiliary function
vc[t_, k_] = w[t, k] /. sol[[1]] t_, k]
(* Out[41]= r^(-1 + t) C[1][k - t] *)
condition (5) reads
sol1 = Solve[vc[0, k] == KroneckerDelta[k, n], C[1][k]]
(* Out[43]= {{C[1][k] -> r KroneckerDelta[k, n]}} *)
Hence the probability for the walker to be at location k at time t if he started at location n>0 (with the basic probability r of jumping one step to the the right) is given by
w[t_, k_, r_, n_] = r^t KroneckerDelta[k - t, n]
(* Out[50]= r^t KroneckerDelta[n, k - t] *)
Example 1:
n=1, r=1/2, w(t,k) is only different from 0 if k=t+1.
The first few values of these non vanishing Terms are
With[{n = 1, r = 1/2}, Table[w[t, t + 1, r, n], {t, 0, 10}]]
(* Out[58]= {1, 1/2, 1/4, 1/8, 1/16, 1/32, 1/64, 1/128, 1/256, 1/512, 1/1024} *)
The complete probabilities form a two dimensional array, which might start like this
With[{n = 3, r = 1/2},
tt = Table[w[t, k, r, n], {t, 0, 5}, {k, 1, 10}]]
(* Out[133]= {{0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 1/2, 0, 0, 0, 0,
0, 0}, {0, 0, 0, 0, 1/4, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 1/8, 0, 0,
0, 0}, {0, 0, 0, 0, 0, 0, 1/16, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 1/
32, 0, 0}} *)
Visualization
ListPlot3D[tt,
PlotLabel ->
"Sysiphos random walk for r=1/2 starting at k=3nProbability w(t,k)
for k>0 as a function of time", PlotRange -> {-0.1, 1},
AxesLabel -> {"k", "t", "w(t,k)"}]
Part 3: discussion
Asymptotic behaviour for large times
The probabilities (6) and (7) at the origin approache a common value
$$w(ttoinfty,0) = frac{1-r}{2-r}tag{9}$$
As the walker must be initially either at the origin or not ("at home or out") the asymptotic value (9) holds for any initial state.
This means that the walker has asymptotically "gone out" with probability
$$w'(ttoinfty,0) = 1- w(ttoinfty,0) = frac{1}{2-r}$$
If the jump probability $r$ is small, it becomes equally probable that the walker is at home or out.
If $rto 1$ the walker is almost certainly out.
Next question: what is the asymptotic shape of the spatial profile? That is what is $w(ttoinfty,k)$ as a function of $k$?
My feeling tells me that is should be exponential ... like the pressure in the atmosphere.
Let's look at it qualitatively: if there were no jumping back, the walker would move away to $ktoinfty$ indefinitely. The jumping back leads to renewed filling from below of, in principle, any position.
What about $w(t,1)$? Let us try to calculate it exactly.
$endgroup$
WARNING sorry, an error in this solution was just pointed out to me by another user. I am busy doing the necessary corrections.
A nice problem. Why not solve it analytically?
Let us use Latex to formulate the problem and write down the solution, and then move to Mathematica. Finally we discuss the results and generalizations.
Part 1: mathematical formulation of the problem
Let $w(t,k)$ be the probability that at time t(>=0) the walker is at position k.
Then let us derive the evolution equations. We do it carefully now because previously I had made an error here.
For $k>0$ we have the balance
$$w(t+1,k) = w(t,k) text{(old value)} - r w(t,k) text{(loss to k+1)}$$
$$+ r w(t,k-1) text{(gain from k-1)}-(1-r)w(t,k) text{(loss to 0)}$$
this gives the equation
$$w(t+1,k) = r; w(t,k-1), ;;;;;tge0, kgt0tag{1}$$
For $k=0$ we have
$$w(t+1,0) = w(t,0)text{(old value)}- r w(t,0)text{(loss to 1)} + (1-r) left(w(t,1)+w(t,2)+...right)text{(gain from all others)}$$
This gives
$$w(t+1,0) = (1-r) sum_{k=0}^infty w(t,k)$$
which greatly simplifies to the simple equation
$$w(t+1,0) = (1-r)tag{2}$$
Indeed, since at any time $tge0$ the walker must be at one of the locations $kge 0$ with certainty we must have
$sum_{k=0}^infty w(t,k)=1$.
In order to finalize the formulation of the problem we need initial conditions.
We assume that the walker at $t=0$ is in location $k=nge0$, i.e.
$$w(0,k)=delta_{k,n}tag{3}$$
where $delta_{k,n}$ is the Kronecker symbol defined as unity if $k=n$ and $0$ otherwise.
Part 2: solution with Mathematica
First we calculate w[t,0]
.
No calculation is necessary because (2) already gives the solution whih is constant for $tgt0$.
This result is independent of the specifiy starting point of the walker: if he would start at $k=0$ then, for t=1 he jumps to $k=1$ with probability $r$ which means that he remains at $k=0$ with probability $1-r$. If he starts at any other location he jumps back to $0$ in the next tmes step with probability $(1-r)$, hence we obtain the same result.
Now we turn to positions k>0.
(still to be checked)
From (1) we have
sol = RSolve[w[t + 1, k] == r w[t, k - 1], w[t, k], {t, k}]
(* Out[43]= {{w[t, k] -> r^(-1 + t) C[1][k - t]}} *)
Don't worry about the strange looking expression of the constant C[1]
with an argument. This is exactly what we need to apply the initial condition (5).
Defining the auxiliary function
vc[t_, k_] = w[t, k] /. sol[[1]] t_, k]
(* Out[41]= r^(-1 + t) C[1][k - t] *)
condition (5) reads
sol1 = Solve[vc[0, k] == KroneckerDelta[k, n], C[1][k]]
(* Out[43]= {{C[1][k] -> r KroneckerDelta[k, n]}} *)
Hence the probability for the walker to be at location k at time t if he started at location n>0 (with the basic probability r of jumping one step to the the right) is given by
w[t_, k_, r_, n_] = r^t KroneckerDelta[k - t, n]
(* Out[50]= r^t KroneckerDelta[n, k - t] *)
Example 1:
n=1, r=1/2, w(t,k) is only different from 0 if k=t+1.
The first few values of these non vanishing Terms are
With[{n = 1, r = 1/2}, Table[w[t, t + 1, r, n], {t, 0, 10}]]
(* Out[58]= {1, 1/2, 1/4, 1/8, 1/16, 1/32, 1/64, 1/128, 1/256, 1/512, 1/1024} *)
The complete probabilities form a two dimensional array, which might start like this
With[{n = 3, r = 1/2},
tt = Table[w[t, k, r, n], {t, 0, 5}, {k, 1, 10}]]
(* Out[133]= {{0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 1/2, 0, 0, 0, 0,
0, 0}, {0, 0, 0, 0, 1/4, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 1/8, 0, 0,
0, 0}, {0, 0, 0, 0, 0, 0, 1/16, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 1/
32, 0, 0}} *)
Visualization
ListPlot3D[tt,
PlotLabel ->
"Sysiphos random walk for r=1/2 starting at k=3nProbability w(t,k)
for k>0 as a function of time", PlotRange -> {-0.1, 1},
AxesLabel -> {"k", "t", "w(t,k)"}]
Part 3: discussion
Asymptotic behaviour for large times
The probabilities (6) and (7) at the origin approache a common value
$$w(ttoinfty,0) = frac{1-r}{2-r}tag{9}$$
As the walker must be initially either at the origin or not ("at home or out") the asymptotic value (9) holds for any initial state.
This means that the walker has asymptotically "gone out" with probability
$$w'(ttoinfty,0) = 1- w(ttoinfty,0) = frac{1}{2-r}$$
If the jump probability $r$ is small, it becomes equally probable that the walker is at home or out.
If $rto 1$ the walker is almost certainly out.
Next question: what is the asymptotic shape of the spatial profile? That is what is $w(ttoinfty,k)$ as a function of $k$?
My feeling tells me that is should be exponential ... like the pressure in the atmosphere.
Let's look at it qualitatively: if there were no jumping back, the walker would move away to $ktoinfty$ indefinitely. The jumping back leads to renewed filling from below of, in principle, any position.
What about $w(t,1)$? Let us try to calculate it exactly.
edited 5 hours ago
answered 11 hours ago
Dr. Wolfgang HintzeDr. Wolfgang Hintze
10.6k839
10.6k839
$begingroup$
Something seems wrong to me. After one time step, the probability to be at the origin (k=0) is 1/2. After a second time step, half of that amount (0.25) is at k=1. That large a probability should be visible on the graph. What am I missing? And could you include k=0 in the above plot?
$endgroup$
– Kieran Mullen
8 hours ago
$begingroup$
@Kieran Mullen Ooops, I'll check it.
$endgroup$
– Dr. Wolfgang Hintze
8 hours ago
$begingroup$
@Kieran Mullen: you are right, I was wrong. Thanks a lot for pointing this out. Thinking more thouroughly I find for a walker starting at $k=0$ that $w(t<k)=0$, $w(t=k) = 1/2^k$, and $w(t>k)=1/2^{k+1}$. Hence the asymptotic profile is indeed exponential. Need to revise my work, not sure which part of it I can save.
$endgroup$
– Dr. Wolfgang Hintze
7 hours ago
add a comment |
$begingroup$
Something seems wrong to me. After one time step, the probability to be at the origin (k=0) is 1/2. After a second time step, half of that amount (0.25) is at k=1. That large a probability should be visible on the graph. What am I missing? And could you include k=0 in the above plot?
$endgroup$
– Kieran Mullen
8 hours ago
$begingroup$
@Kieran Mullen Ooops, I'll check it.
$endgroup$
– Dr. Wolfgang Hintze
8 hours ago
$begingroup$
@Kieran Mullen: you are right, I was wrong. Thanks a lot for pointing this out. Thinking more thouroughly I find for a walker starting at $k=0$ that $w(t<k)=0$, $w(t=k) = 1/2^k$, and $w(t>k)=1/2^{k+1}$. Hence the asymptotic profile is indeed exponential. Need to revise my work, not sure which part of it I can save.
$endgroup$
– Dr. Wolfgang Hintze
7 hours ago
$begingroup$
Something seems wrong to me. After one time step, the probability to be at the origin (k=0) is 1/2. After a second time step, half of that amount (0.25) is at k=1. That large a probability should be visible on the graph. What am I missing? And could you include k=0 in the above plot?
$endgroup$
– Kieran Mullen
8 hours ago
$begingroup$
Something seems wrong to me. After one time step, the probability to be at the origin (k=0) is 1/2. After a second time step, half of that amount (0.25) is at k=1. That large a probability should be visible on the graph. What am I missing? And could you include k=0 in the above plot?
$endgroup$
– Kieran Mullen
8 hours ago
$begingroup$
@Kieran Mullen Ooops, I'll check it.
$endgroup$
– Dr. Wolfgang Hintze
8 hours ago
$begingroup$
@Kieran Mullen Ooops, I'll check it.
$endgroup$
– Dr. Wolfgang Hintze
8 hours ago
$begingroup$
@Kieran Mullen: you are right, I was wrong. Thanks a lot for pointing this out. Thinking more thouroughly I find for a walker starting at $k=0$ that $w(t<k)=0$, $w(t=k) = 1/2^k$, and $w(t>k)=1/2^{k+1}$. Hence the asymptotic profile is indeed exponential. Need to revise my work, not sure which part of it I can save.
$endgroup$
– Dr. Wolfgang Hintze
7 hours ago
$begingroup$
@Kieran Mullen: you are right, I was wrong. Thanks a lot for pointing this out. Thinking more thouroughly I find for a walker starting at $k=0$ that $w(t<k)=0$, $w(t=k) = 1/2^k$, and $w(t>k)=1/2^{k+1}$. Hence the asymptotic profile is indeed exponential. Need to revise my work, not sure which part of it I can save.
$endgroup$
– Dr. Wolfgang Hintze
7 hours ago
add a comment |
Thanks for contributing an answer to Mathematica 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.
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%2fmathematica.stackexchange.com%2fquestions%2f189764%2fsisyphus-random-walk%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
$begingroup$
closely related: Faster “stuttering” accumulate
$endgroup$
– kglr
5 hours ago