Brownian motion and rotated normal distribution
I found this interesting and (I believe) quite pedagogic representation of a brownian motion and its related normal distribution at a specific time forward.
Tikz Brownian motion explains how to draw a brownian motion and Rotated normal distribution explains how to draw the rotated normal.
I join MWE below. At my level, it'd far too manual to match the graph and the center of the distribution.
Is there a way to link the distribution and the brownian motion so that it shows how the brownian grows in $sqrt(T)$. As a result, the graph on $T=100$ shows a narrower distribution than on $T=400$ ?
documentclass{standalone}
usepackage{tikz}
begin{document}
%Brownian motion
newcommand{BM}[5]{
% points, advance, rand factor, options, end label
draw[#4] (0,0)
foreach x in {1,...,#1}
{ -- ++(#2,rand*#3)
}
node[right] {#5};
}
begin{tikzpicture}[
declare function= {gauss(x,y,z)=offset+1/(y*sqrt(2*pi))*exp(-((x-z)^2)/(2*y^2));}]
pgfmathsetseed{17}
draw[help lines] (0,-5) grid (15,5);
BM{100}{0.02}{0.2}{red}{$BM_1$};
draw (2,-5) -- (2,5) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
draw[-latex] (2,0) -- (4,0) node[below left,rotate=-90]{};
BM{600}{0.02}{0.2}{blue}{$BM_3$}
end{tikzpicture}
end{document}
Merci !
tikz-pgf
|
show 2 more comments
I found this interesting and (I believe) quite pedagogic representation of a brownian motion and its related normal distribution at a specific time forward.
Tikz Brownian motion explains how to draw a brownian motion and Rotated normal distribution explains how to draw the rotated normal.
I join MWE below. At my level, it'd far too manual to match the graph and the center of the distribution.
Is there a way to link the distribution and the brownian motion so that it shows how the brownian grows in $sqrt(T)$. As a result, the graph on $T=100$ shows a narrower distribution than on $T=400$ ?
documentclass{standalone}
usepackage{tikz}
begin{document}
%Brownian motion
newcommand{BM}[5]{
% points, advance, rand factor, options, end label
draw[#4] (0,0)
foreach x in {1,...,#1}
{ -- ++(#2,rand*#3)
}
node[right] {#5};
}
begin{tikzpicture}[
declare function= {gauss(x,y,z)=offset+1/(y*sqrt(2*pi))*exp(-((x-z)^2)/(2*y^2));}]
pgfmathsetseed{17}
draw[help lines] (0,-5) grid (15,5);
BM{100}{0.02}{0.2}{red}{$BM_1$};
draw (2,-5) -- (2,5) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
draw[-latex] (2,0) -- (4,0) node[below left,rotate=-90]{};
BM{600}{0.02}{0.2}{blue}{$BM_3$}
end{tikzpicture}
end{document}
Merci !
tikz-pgf
Hi Marmot, I tried to sketch something. I want to show there is an effect on where the brownian can be at a future point $t$ depending on the distance from $s$ to this future point $(t-s)$. The distribution of probability is a Gaussian with a variance $sqrt{(t-s)}$
– Julien-Elie Taieb
Jan 2 at 20:25
1
I updated the details on my initial question. The variance of the distribution is determined by the distance to the future point we try to simulate. The farer the point, the wider the distribution.
– Julien-Elie Taieb
Jan 2 at 20:51
Its definitiely the right direction and even better with the animation feature. May I just add one thing ? the projection should be on a straight vertical line and not on the distribution itself. It shows the idea of the potential impact at that specific time and how it is distributed.
– Julien-Elie Taieb
Jan 2 at 21:39
Let us continue this discussion in chat.
– Julien-Elie Taieb
Jan 2 at 21:46
@Julien-ElieTaieb This seems to be a little bit unscientific/undidactic. The probability distribution applies before the time has passed, but the shown Brownian motion applies after the time has passed.
– Toscho
Jan 2 at 21:57
|
show 2 more comments
I found this interesting and (I believe) quite pedagogic representation of a brownian motion and its related normal distribution at a specific time forward.
Tikz Brownian motion explains how to draw a brownian motion and Rotated normal distribution explains how to draw the rotated normal.
I join MWE below. At my level, it'd far too manual to match the graph and the center of the distribution.
Is there a way to link the distribution and the brownian motion so that it shows how the brownian grows in $sqrt(T)$. As a result, the graph on $T=100$ shows a narrower distribution than on $T=400$ ?
documentclass{standalone}
usepackage{tikz}
begin{document}
%Brownian motion
newcommand{BM}[5]{
% points, advance, rand factor, options, end label
draw[#4] (0,0)
foreach x in {1,...,#1}
{ -- ++(#2,rand*#3)
}
node[right] {#5};
}
begin{tikzpicture}[
declare function= {gauss(x,y,z)=offset+1/(y*sqrt(2*pi))*exp(-((x-z)^2)/(2*y^2));}]
pgfmathsetseed{17}
draw[help lines] (0,-5) grid (15,5);
BM{100}{0.02}{0.2}{red}{$BM_1$};
draw (2,-5) -- (2,5) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
draw[-latex] (2,0) -- (4,0) node[below left,rotate=-90]{};
BM{600}{0.02}{0.2}{blue}{$BM_3$}
end{tikzpicture}
end{document}
Merci !
tikz-pgf
I found this interesting and (I believe) quite pedagogic representation of a brownian motion and its related normal distribution at a specific time forward.
Tikz Brownian motion explains how to draw a brownian motion and Rotated normal distribution explains how to draw the rotated normal.
I join MWE below. At my level, it'd far too manual to match the graph and the center of the distribution.
Is there a way to link the distribution and the brownian motion so that it shows how the brownian grows in $sqrt(T)$. As a result, the graph on $T=100$ shows a narrower distribution than on $T=400$ ?
documentclass{standalone}
usepackage{tikz}
begin{document}
%Brownian motion
newcommand{BM}[5]{
% points, advance, rand factor, options, end label
draw[#4] (0,0)
foreach x in {1,...,#1}
{ -- ++(#2,rand*#3)
}
node[right] {#5};
}
begin{tikzpicture}[
declare function= {gauss(x,y,z)=offset+1/(y*sqrt(2*pi))*exp(-((x-z)^2)/(2*y^2));}]
pgfmathsetseed{17}
draw[help lines] (0,-5) grid (15,5);
BM{100}{0.02}{0.2}{red}{$BM_1$};
draw (2,-5) -- (2,5) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
draw[-latex] (2,0) -- (4,0) node[below left,rotate=-90]{};
BM{600}{0.02}{0.2}{blue}{$BM_3$}
end{tikzpicture}
end{document}
Merci !
tikz-pgf
tikz-pgf
edited Jan 2 at 20:51
Julien-Elie Taieb
asked Jan 2 at 20:08
Julien-Elie TaiebJulien-Elie Taieb
12919
12919
Hi Marmot, I tried to sketch something. I want to show there is an effect on where the brownian can be at a future point $t$ depending on the distance from $s$ to this future point $(t-s)$. The distribution of probability is a Gaussian with a variance $sqrt{(t-s)}$
– Julien-Elie Taieb
Jan 2 at 20:25
1
I updated the details on my initial question. The variance of the distribution is determined by the distance to the future point we try to simulate. The farer the point, the wider the distribution.
– Julien-Elie Taieb
Jan 2 at 20:51
Its definitiely the right direction and even better with the animation feature. May I just add one thing ? the projection should be on a straight vertical line and not on the distribution itself. It shows the idea of the potential impact at that specific time and how it is distributed.
– Julien-Elie Taieb
Jan 2 at 21:39
Let us continue this discussion in chat.
– Julien-Elie Taieb
Jan 2 at 21:46
@Julien-ElieTaieb This seems to be a little bit unscientific/undidactic. The probability distribution applies before the time has passed, but the shown Brownian motion applies after the time has passed.
– Toscho
Jan 2 at 21:57
|
show 2 more comments
Hi Marmot, I tried to sketch something. I want to show there is an effect on where the brownian can be at a future point $t$ depending on the distance from $s$ to this future point $(t-s)$. The distribution of probability is a Gaussian with a variance $sqrt{(t-s)}$
– Julien-Elie Taieb
Jan 2 at 20:25
1
I updated the details on my initial question. The variance of the distribution is determined by the distance to the future point we try to simulate. The farer the point, the wider the distribution.
– Julien-Elie Taieb
Jan 2 at 20:51
Its definitiely the right direction and even better with the animation feature. May I just add one thing ? the projection should be on a straight vertical line and not on the distribution itself. It shows the idea of the potential impact at that specific time and how it is distributed.
– Julien-Elie Taieb
Jan 2 at 21:39
Let us continue this discussion in chat.
– Julien-Elie Taieb
Jan 2 at 21:46
@Julien-ElieTaieb This seems to be a little bit unscientific/undidactic. The probability distribution applies before the time has passed, but the shown Brownian motion applies after the time has passed.
– Toscho
Jan 2 at 21:57
Hi Marmot, I tried to sketch something. I want to show there is an effect on where the brownian can be at a future point $t$ depending on the distance from $s$ to this future point $(t-s)$. The distribution of probability is a Gaussian with a variance $sqrt{(t-s)}$
– Julien-Elie Taieb
Jan 2 at 20:25
Hi Marmot, I tried to sketch something. I want to show there is an effect on where the brownian can be at a future point $t$ depending on the distance from $s$ to this future point $(t-s)$. The distribution of probability is a Gaussian with a variance $sqrt{(t-s)}$
– Julien-Elie Taieb
Jan 2 at 20:25
1
1
I updated the details on my initial question. The variance of the distribution is determined by the distance to the future point we try to simulate. The farer the point, the wider the distribution.
– Julien-Elie Taieb
Jan 2 at 20:51
I updated the details on my initial question. The variance of the distribution is determined by the distance to the future point we try to simulate. The farer the point, the wider the distribution.
– Julien-Elie Taieb
Jan 2 at 20:51
Its definitiely the right direction and even better with the animation feature. May I just add one thing ? the projection should be on a straight vertical line and not on the distribution itself. It shows the idea of the potential impact at that specific time and how it is distributed.
– Julien-Elie Taieb
Jan 2 at 21:39
Its definitiely the right direction and even better with the animation feature. May I just add one thing ? the projection should be on a straight vertical line and not on the distribution itself. It shows the idea of the potential impact at that specific time and how it is distributed.
– Julien-Elie Taieb
Jan 2 at 21:39
Let us continue this discussion in chat.
– Julien-Elie Taieb
Jan 2 at 21:46
Let us continue this discussion in chat.
– Julien-Elie Taieb
Jan 2 at 21:46
@Julien-ElieTaieb This seems to be a little bit unscientific/undidactic. The probability distribution applies before the time has passed, but the shown Brownian motion applies after the time has passed.
– Toscho
Jan 2 at 21:57
@Julien-ElieTaieb This seems to be a little bit unscientific/undidactic. The probability distribution applies before the time has passed, but the shown Brownian motion applies after the time has passed.
– Toscho
Jan 2 at 21:57
|
show 2 more comments
1 Answer
1
active
oldest
votes
An attempt to clean up. It shows what (I think) we agreed on in this chat. The answer comes in two variations:
- A more boring version which has a Gaussian that just moves to the right and gets wider.
- A more funky version in which the Gaussian follows a path. (There are no claims attached that this version has a clear physical interpretation, but it leads to a more interesting animation. ;-)
Let's start with the boring version.
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{calc}
begin{document}
%Brownian motion
newcommand{BM}[5]{
% points, advance, rand factor, options, end label
draw[#4] (0,0)
foreach x in {1,...,#1}
{ -- ++(#2,rand*#3) coordinate (aux-x) % <- added coordinate names
}
node[right] {#5};
}
newcommand{AddHorizontalGauss}[3]{
draw[#1] let p1=(aux-#2),p2=(aux-#3),n1={0.5*sqrt((x2-x1)*1pt/1cm)},
n2={3*n1},n3={0.895*n2} in pgfextra{pgfmathsetmacro{ymax}{n2}
pgfmathsetmacro{ynext}{n3}}
plot[variable=z,domain=-ymax:ymax,samples=101]
({x2+3*gauss(z,n1,0)*1cm},{y1+z*1cm})
($(x2,y1)+(0,-ymax)$) -- ($(x2,y1)+(0,ymax)$)
foreach X in {-ymax,-ynext,...,ymax}
{ (p1) -- ($(x2,y1)+({0*gauss(X,n1,0)},X*1cm)$)};
}
begin{tikzpicture}[
declare function={gauss(x,y,z)=1/(y*sqrt(2*pi))*exp(-((x-z)^2)/(2*y^2));}]
pgfmathsetseed{17}
draw[help lines] (0,-8) grid (15,8);
BM{100}{0.02}{0.2}{red}{$BM_1$};
draw (2,-5) -- (2,5) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
draw[-latex] (2,0) -- (4,0) node[below left,rotate=-90]{};
BM{600}{0.02}{0.2}{blue}{$BM_3$}
AddHorizontalGauss{100}{510}
end{tikzpicture}
end{document}
This can be made an animation.
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{calc}
begin{document}
%Brownian motion
newcommand{BM}[5]{
% points, advance, rand factor, options, end label
draw[#4] (0,0)
foreach x in {1,...,#1}
{ -- ++(#2,rand*#3) coordinate (aux-x) % <- added coordinate names
}
node[right] {#5};
}
newcommand{AddHorizontalGauss}[3]{
draw[#1] let p1=(aux-#2),p2=(aux-#3),n1={0.5*sqrt((x2-x1)*1pt/1cm)},
n2={3*n1},n3={0.895*n2} in pgfextra{pgfmathsetmacro{ymax}{n2}
pgfmathsetmacro{ynext}{n3}}
plot[variable=z,domain=-ymax:ymax,samples=101]
({x2+3*gauss(z,n1,0)*1cm},{y1+z*1cm})
($(x2,y1)+(0,-ymax)$) -- ($(x2,y1)+(0,ymax)$)
foreach X in {-ymax,-ynext,...,ymax}
{ (p1) -- ($(x2,y1)+({0*gauss(X,n1,0)},X*1cm)$)};
}
foreach Z in {120,130,...,540}
{begin{tikzpicture}[
declare function={gauss(x,y,z)=1/(y*sqrt(2*pi))*exp(-((x-z)^2)/(2*y^2));}]
pgfmathsetseed{17}
draw[help lines] (0,-8) grid (15,8);
BM{100}{0.02}{0.2}{red}{$BM_1$};
draw (2,-5) -- (2,5) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
draw[-latex] (2,0) -- (4,0) node[below left,rotate=-90]{};
BM{600}{0.02}{0.2}{blue}{$BM_3$}
AddHorizontalGauss{100}{Z}
end{tikzpicture}}
end{document}
Note that I have not computed the prefactor of the variance. This is just a cartoon. But this code will allow those who have a real random walk problem and compute the prefactor to produce a more realistic animation.
Now comes the comoving Gaussian. (To keep the answer reasonably "short" I only show the animation.)
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{calc}
begin{document}
%Brownian motion
newcommand{BM}[5]{
% points, advance, rand factor, options, end label
draw[#4] (0,0)
foreach x in {1,...,#1}
{ -- ++(#2,rand*#3) coordinate (aux-x) % <- added coordinate names
}
node[right] {#5};
}
newcommand{AddComovingGauss}[3]{
draw[#1] let p1=(aux-#2),p2=(aux-#3),n1={0.5*sqrt((x2-x1)*1pt/1cm)},
n2={3*n1},n3={0.89*n2} in pgfextra{pgfmathsetmacro{ymax}{n2}
pgfmathsetmacro{ynext}{n3}}
plot[variable=z,domain=-ymax:ymax,samples=101]
({x2+3*gauss(z,n1,0)*1cm},{y2+z*1cm})
($(p2)+(0,-ymax)$) -- ($(p2)+(0,ymax)$)
foreach X in {-ymax,-ynext,...,ymax}
{ (p1) -- ($(p2)+({0*gauss(X,n1,0)},X*1cm)$)};
}
foreach Z in {120,130,...,540}
{begin{tikzpicture}[
declare function={gauss(x,y,z)=1/(y*sqrt(2*pi))*exp(-((x-z)^2)/(2*y^2));}]
pgfmathsetseed{17}
draw[help lines] (0,-8) grid (15,8);
BM{100}{0.02}{0.2}{red}{$BM_1$};
draw (2,-5) -- (2,5) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
draw[-latex] (2,0) -- (4,0) node[below left,rotate=-90]{};
BM{600}{0.02}{0.2}{blue}{$BM_3$}
AddComovingGauss{100}{Z}
end{tikzpicture}}
end{document}
And I also know that one could make the code somewhat shorter. This is an attempt to keep it very accessible.
The animation is beathtaking !!
– Julien-Elie Taieb
Jan 2 at 21:13
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
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%2ftex.stackexchange.com%2fquestions%2f468312%2fbrownian-motion-and-rotated-normal-distribution%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
An attempt to clean up. It shows what (I think) we agreed on in this chat. The answer comes in two variations:
- A more boring version which has a Gaussian that just moves to the right and gets wider.
- A more funky version in which the Gaussian follows a path. (There are no claims attached that this version has a clear physical interpretation, but it leads to a more interesting animation. ;-)
Let's start with the boring version.
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{calc}
begin{document}
%Brownian motion
newcommand{BM}[5]{
% points, advance, rand factor, options, end label
draw[#4] (0,0)
foreach x in {1,...,#1}
{ -- ++(#2,rand*#3) coordinate (aux-x) % <- added coordinate names
}
node[right] {#5};
}
newcommand{AddHorizontalGauss}[3]{
draw[#1] let p1=(aux-#2),p2=(aux-#3),n1={0.5*sqrt((x2-x1)*1pt/1cm)},
n2={3*n1},n3={0.895*n2} in pgfextra{pgfmathsetmacro{ymax}{n2}
pgfmathsetmacro{ynext}{n3}}
plot[variable=z,domain=-ymax:ymax,samples=101]
({x2+3*gauss(z,n1,0)*1cm},{y1+z*1cm})
($(x2,y1)+(0,-ymax)$) -- ($(x2,y1)+(0,ymax)$)
foreach X in {-ymax,-ynext,...,ymax}
{ (p1) -- ($(x2,y1)+({0*gauss(X,n1,0)},X*1cm)$)};
}
begin{tikzpicture}[
declare function={gauss(x,y,z)=1/(y*sqrt(2*pi))*exp(-((x-z)^2)/(2*y^2));}]
pgfmathsetseed{17}
draw[help lines] (0,-8) grid (15,8);
BM{100}{0.02}{0.2}{red}{$BM_1$};
draw (2,-5) -- (2,5) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
draw[-latex] (2,0) -- (4,0) node[below left,rotate=-90]{};
BM{600}{0.02}{0.2}{blue}{$BM_3$}
AddHorizontalGauss{100}{510}
end{tikzpicture}
end{document}
This can be made an animation.
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{calc}
begin{document}
%Brownian motion
newcommand{BM}[5]{
% points, advance, rand factor, options, end label
draw[#4] (0,0)
foreach x in {1,...,#1}
{ -- ++(#2,rand*#3) coordinate (aux-x) % <- added coordinate names
}
node[right] {#5};
}
newcommand{AddHorizontalGauss}[3]{
draw[#1] let p1=(aux-#2),p2=(aux-#3),n1={0.5*sqrt((x2-x1)*1pt/1cm)},
n2={3*n1},n3={0.895*n2} in pgfextra{pgfmathsetmacro{ymax}{n2}
pgfmathsetmacro{ynext}{n3}}
plot[variable=z,domain=-ymax:ymax,samples=101]
({x2+3*gauss(z,n1,0)*1cm},{y1+z*1cm})
($(x2,y1)+(0,-ymax)$) -- ($(x2,y1)+(0,ymax)$)
foreach X in {-ymax,-ynext,...,ymax}
{ (p1) -- ($(x2,y1)+({0*gauss(X,n1,0)},X*1cm)$)};
}
foreach Z in {120,130,...,540}
{begin{tikzpicture}[
declare function={gauss(x,y,z)=1/(y*sqrt(2*pi))*exp(-((x-z)^2)/(2*y^2));}]
pgfmathsetseed{17}
draw[help lines] (0,-8) grid (15,8);
BM{100}{0.02}{0.2}{red}{$BM_1$};
draw (2,-5) -- (2,5) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
draw[-latex] (2,0) -- (4,0) node[below left,rotate=-90]{};
BM{600}{0.02}{0.2}{blue}{$BM_3$}
AddHorizontalGauss{100}{Z}
end{tikzpicture}}
end{document}
Note that I have not computed the prefactor of the variance. This is just a cartoon. But this code will allow those who have a real random walk problem and compute the prefactor to produce a more realistic animation.
Now comes the comoving Gaussian. (To keep the answer reasonably "short" I only show the animation.)
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{calc}
begin{document}
%Brownian motion
newcommand{BM}[5]{
% points, advance, rand factor, options, end label
draw[#4] (0,0)
foreach x in {1,...,#1}
{ -- ++(#2,rand*#3) coordinate (aux-x) % <- added coordinate names
}
node[right] {#5};
}
newcommand{AddComovingGauss}[3]{
draw[#1] let p1=(aux-#2),p2=(aux-#3),n1={0.5*sqrt((x2-x1)*1pt/1cm)},
n2={3*n1},n3={0.89*n2} in pgfextra{pgfmathsetmacro{ymax}{n2}
pgfmathsetmacro{ynext}{n3}}
plot[variable=z,domain=-ymax:ymax,samples=101]
({x2+3*gauss(z,n1,0)*1cm},{y2+z*1cm})
($(p2)+(0,-ymax)$) -- ($(p2)+(0,ymax)$)
foreach X in {-ymax,-ynext,...,ymax}
{ (p1) -- ($(p2)+({0*gauss(X,n1,0)},X*1cm)$)};
}
foreach Z in {120,130,...,540}
{begin{tikzpicture}[
declare function={gauss(x,y,z)=1/(y*sqrt(2*pi))*exp(-((x-z)^2)/(2*y^2));}]
pgfmathsetseed{17}
draw[help lines] (0,-8) grid (15,8);
BM{100}{0.02}{0.2}{red}{$BM_1$};
draw (2,-5) -- (2,5) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
draw[-latex] (2,0) -- (4,0) node[below left,rotate=-90]{};
BM{600}{0.02}{0.2}{blue}{$BM_3$}
AddComovingGauss{100}{Z}
end{tikzpicture}}
end{document}
And I also know that one could make the code somewhat shorter. This is an attempt to keep it very accessible.
The animation is beathtaking !!
– Julien-Elie Taieb
Jan 2 at 21:13
add a comment |
An attempt to clean up. It shows what (I think) we agreed on in this chat. The answer comes in two variations:
- A more boring version which has a Gaussian that just moves to the right and gets wider.
- A more funky version in which the Gaussian follows a path. (There are no claims attached that this version has a clear physical interpretation, but it leads to a more interesting animation. ;-)
Let's start with the boring version.
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{calc}
begin{document}
%Brownian motion
newcommand{BM}[5]{
% points, advance, rand factor, options, end label
draw[#4] (0,0)
foreach x in {1,...,#1}
{ -- ++(#2,rand*#3) coordinate (aux-x) % <- added coordinate names
}
node[right] {#5};
}
newcommand{AddHorizontalGauss}[3]{
draw[#1] let p1=(aux-#2),p2=(aux-#3),n1={0.5*sqrt((x2-x1)*1pt/1cm)},
n2={3*n1},n3={0.895*n2} in pgfextra{pgfmathsetmacro{ymax}{n2}
pgfmathsetmacro{ynext}{n3}}
plot[variable=z,domain=-ymax:ymax,samples=101]
({x2+3*gauss(z,n1,0)*1cm},{y1+z*1cm})
($(x2,y1)+(0,-ymax)$) -- ($(x2,y1)+(0,ymax)$)
foreach X in {-ymax,-ynext,...,ymax}
{ (p1) -- ($(x2,y1)+({0*gauss(X,n1,0)},X*1cm)$)};
}
begin{tikzpicture}[
declare function={gauss(x,y,z)=1/(y*sqrt(2*pi))*exp(-((x-z)^2)/(2*y^2));}]
pgfmathsetseed{17}
draw[help lines] (0,-8) grid (15,8);
BM{100}{0.02}{0.2}{red}{$BM_1$};
draw (2,-5) -- (2,5) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
draw[-latex] (2,0) -- (4,0) node[below left,rotate=-90]{};
BM{600}{0.02}{0.2}{blue}{$BM_3$}
AddHorizontalGauss{100}{510}
end{tikzpicture}
end{document}
This can be made an animation.
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{calc}
begin{document}
%Brownian motion
newcommand{BM}[5]{
% points, advance, rand factor, options, end label
draw[#4] (0,0)
foreach x in {1,...,#1}
{ -- ++(#2,rand*#3) coordinate (aux-x) % <- added coordinate names
}
node[right] {#5};
}
newcommand{AddHorizontalGauss}[3]{
draw[#1] let p1=(aux-#2),p2=(aux-#3),n1={0.5*sqrt((x2-x1)*1pt/1cm)},
n2={3*n1},n3={0.895*n2} in pgfextra{pgfmathsetmacro{ymax}{n2}
pgfmathsetmacro{ynext}{n3}}
plot[variable=z,domain=-ymax:ymax,samples=101]
({x2+3*gauss(z,n1,0)*1cm},{y1+z*1cm})
($(x2,y1)+(0,-ymax)$) -- ($(x2,y1)+(0,ymax)$)
foreach X in {-ymax,-ynext,...,ymax}
{ (p1) -- ($(x2,y1)+({0*gauss(X,n1,0)},X*1cm)$)};
}
foreach Z in {120,130,...,540}
{begin{tikzpicture}[
declare function={gauss(x,y,z)=1/(y*sqrt(2*pi))*exp(-((x-z)^2)/(2*y^2));}]
pgfmathsetseed{17}
draw[help lines] (0,-8) grid (15,8);
BM{100}{0.02}{0.2}{red}{$BM_1$};
draw (2,-5) -- (2,5) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
draw[-latex] (2,0) -- (4,0) node[below left,rotate=-90]{};
BM{600}{0.02}{0.2}{blue}{$BM_3$}
AddHorizontalGauss{100}{Z}
end{tikzpicture}}
end{document}
Note that I have not computed the prefactor of the variance. This is just a cartoon. But this code will allow those who have a real random walk problem and compute the prefactor to produce a more realistic animation.
Now comes the comoving Gaussian. (To keep the answer reasonably "short" I only show the animation.)
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{calc}
begin{document}
%Brownian motion
newcommand{BM}[5]{
% points, advance, rand factor, options, end label
draw[#4] (0,0)
foreach x in {1,...,#1}
{ -- ++(#2,rand*#3) coordinate (aux-x) % <- added coordinate names
}
node[right] {#5};
}
newcommand{AddComovingGauss}[3]{
draw[#1] let p1=(aux-#2),p2=(aux-#3),n1={0.5*sqrt((x2-x1)*1pt/1cm)},
n2={3*n1},n3={0.89*n2} in pgfextra{pgfmathsetmacro{ymax}{n2}
pgfmathsetmacro{ynext}{n3}}
plot[variable=z,domain=-ymax:ymax,samples=101]
({x2+3*gauss(z,n1,0)*1cm},{y2+z*1cm})
($(p2)+(0,-ymax)$) -- ($(p2)+(0,ymax)$)
foreach X in {-ymax,-ynext,...,ymax}
{ (p1) -- ($(p2)+({0*gauss(X,n1,0)},X*1cm)$)};
}
foreach Z in {120,130,...,540}
{begin{tikzpicture}[
declare function={gauss(x,y,z)=1/(y*sqrt(2*pi))*exp(-((x-z)^2)/(2*y^2));}]
pgfmathsetseed{17}
draw[help lines] (0,-8) grid (15,8);
BM{100}{0.02}{0.2}{red}{$BM_1$};
draw (2,-5) -- (2,5) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
draw[-latex] (2,0) -- (4,0) node[below left,rotate=-90]{};
BM{600}{0.02}{0.2}{blue}{$BM_3$}
AddComovingGauss{100}{Z}
end{tikzpicture}}
end{document}
And I also know that one could make the code somewhat shorter. This is an attempt to keep it very accessible.
The animation is beathtaking !!
– Julien-Elie Taieb
Jan 2 at 21:13
add a comment |
An attempt to clean up. It shows what (I think) we agreed on in this chat. The answer comes in two variations:
- A more boring version which has a Gaussian that just moves to the right and gets wider.
- A more funky version in which the Gaussian follows a path. (There are no claims attached that this version has a clear physical interpretation, but it leads to a more interesting animation. ;-)
Let's start with the boring version.
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{calc}
begin{document}
%Brownian motion
newcommand{BM}[5]{
% points, advance, rand factor, options, end label
draw[#4] (0,0)
foreach x in {1,...,#1}
{ -- ++(#2,rand*#3) coordinate (aux-x) % <- added coordinate names
}
node[right] {#5};
}
newcommand{AddHorizontalGauss}[3]{
draw[#1] let p1=(aux-#2),p2=(aux-#3),n1={0.5*sqrt((x2-x1)*1pt/1cm)},
n2={3*n1},n3={0.895*n2} in pgfextra{pgfmathsetmacro{ymax}{n2}
pgfmathsetmacro{ynext}{n3}}
plot[variable=z,domain=-ymax:ymax,samples=101]
({x2+3*gauss(z,n1,0)*1cm},{y1+z*1cm})
($(x2,y1)+(0,-ymax)$) -- ($(x2,y1)+(0,ymax)$)
foreach X in {-ymax,-ynext,...,ymax}
{ (p1) -- ($(x2,y1)+({0*gauss(X,n1,0)},X*1cm)$)};
}
begin{tikzpicture}[
declare function={gauss(x,y,z)=1/(y*sqrt(2*pi))*exp(-((x-z)^2)/(2*y^2));}]
pgfmathsetseed{17}
draw[help lines] (0,-8) grid (15,8);
BM{100}{0.02}{0.2}{red}{$BM_1$};
draw (2,-5) -- (2,5) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
draw[-latex] (2,0) -- (4,0) node[below left,rotate=-90]{};
BM{600}{0.02}{0.2}{blue}{$BM_3$}
AddHorizontalGauss{100}{510}
end{tikzpicture}
end{document}
This can be made an animation.
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{calc}
begin{document}
%Brownian motion
newcommand{BM}[5]{
% points, advance, rand factor, options, end label
draw[#4] (0,0)
foreach x in {1,...,#1}
{ -- ++(#2,rand*#3) coordinate (aux-x) % <- added coordinate names
}
node[right] {#5};
}
newcommand{AddHorizontalGauss}[3]{
draw[#1] let p1=(aux-#2),p2=(aux-#3),n1={0.5*sqrt((x2-x1)*1pt/1cm)},
n2={3*n1},n3={0.895*n2} in pgfextra{pgfmathsetmacro{ymax}{n2}
pgfmathsetmacro{ynext}{n3}}
plot[variable=z,domain=-ymax:ymax,samples=101]
({x2+3*gauss(z,n1,0)*1cm},{y1+z*1cm})
($(x2,y1)+(0,-ymax)$) -- ($(x2,y1)+(0,ymax)$)
foreach X in {-ymax,-ynext,...,ymax}
{ (p1) -- ($(x2,y1)+({0*gauss(X,n1,0)},X*1cm)$)};
}
foreach Z in {120,130,...,540}
{begin{tikzpicture}[
declare function={gauss(x,y,z)=1/(y*sqrt(2*pi))*exp(-((x-z)^2)/(2*y^2));}]
pgfmathsetseed{17}
draw[help lines] (0,-8) grid (15,8);
BM{100}{0.02}{0.2}{red}{$BM_1$};
draw (2,-5) -- (2,5) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
draw[-latex] (2,0) -- (4,0) node[below left,rotate=-90]{};
BM{600}{0.02}{0.2}{blue}{$BM_3$}
AddHorizontalGauss{100}{Z}
end{tikzpicture}}
end{document}
Note that I have not computed the prefactor of the variance. This is just a cartoon. But this code will allow those who have a real random walk problem and compute the prefactor to produce a more realistic animation.
Now comes the comoving Gaussian. (To keep the answer reasonably "short" I only show the animation.)
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{calc}
begin{document}
%Brownian motion
newcommand{BM}[5]{
% points, advance, rand factor, options, end label
draw[#4] (0,0)
foreach x in {1,...,#1}
{ -- ++(#2,rand*#3) coordinate (aux-x) % <- added coordinate names
}
node[right] {#5};
}
newcommand{AddComovingGauss}[3]{
draw[#1] let p1=(aux-#2),p2=(aux-#3),n1={0.5*sqrt((x2-x1)*1pt/1cm)},
n2={3*n1},n3={0.89*n2} in pgfextra{pgfmathsetmacro{ymax}{n2}
pgfmathsetmacro{ynext}{n3}}
plot[variable=z,domain=-ymax:ymax,samples=101]
({x2+3*gauss(z,n1,0)*1cm},{y2+z*1cm})
($(p2)+(0,-ymax)$) -- ($(p2)+(0,ymax)$)
foreach X in {-ymax,-ynext,...,ymax}
{ (p1) -- ($(p2)+({0*gauss(X,n1,0)},X*1cm)$)};
}
foreach Z in {120,130,...,540}
{begin{tikzpicture}[
declare function={gauss(x,y,z)=1/(y*sqrt(2*pi))*exp(-((x-z)^2)/(2*y^2));}]
pgfmathsetseed{17}
draw[help lines] (0,-8) grid (15,8);
BM{100}{0.02}{0.2}{red}{$BM_1$};
draw (2,-5) -- (2,5) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
draw[-latex] (2,0) -- (4,0) node[below left,rotate=-90]{};
BM{600}{0.02}{0.2}{blue}{$BM_3$}
AddComovingGauss{100}{Z}
end{tikzpicture}}
end{document}
And I also know that one could make the code somewhat shorter. This is an attempt to keep it very accessible.
An attempt to clean up. It shows what (I think) we agreed on in this chat. The answer comes in two variations:
- A more boring version which has a Gaussian that just moves to the right and gets wider.
- A more funky version in which the Gaussian follows a path. (There are no claims attached that this version has a clear physical interpretation, but it leads to a more interesting animation. ;-)
Let's start with the boring version.
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{calc}
begin{document}
%Brownian motion
newcommand{BM}[5]{
% points, advance, rand factor, options, end label
draw[#4] (0,0)
foreach x in {1,...,#1}
{ -- ++(#2,rand*#3) coordinate (aux-x) % <- added coordinate names
}
node[right] {#5};
}
newcommand{AddHorizontalGauss}[3]{
draw[#1] let p1=(aux-#2),p2=(aux-#3),n1={0.5*sqrt((x2-x1)*1pt/1cm)},
n2={3*n1},n3={0.895*n2} in pgfextra{pgfmathsetmacro{ymax}{n2}
pgfmathsetmacro{ynext}{n3}}
plot[variable=z,domain=-ymax:ymax,samples=101]
({x2+3*gauss(z,n1,0)*1cm},{y1+z*1cm})
($(x2,y1)+(0,-ymax)$) -- ($(x2,y1)+(0,ymax)$)
foreach X in {-ymax,-ynext,...,ymax}
{ (p1) -- ($(x2,y1)+({0*gauss(X,n1,0)},X*1cm)$)};
}
begin{tikzpicture}[
declare function={gauss(x,y,z)=1/(y*sqrt(2*pi))*exp(-((x-z)^2)/(2*y^2));}]
pgfmathsetseed{17}
draw[help lines] (0,-8) grid (15,8);
BM{100}{0.02}{0.2}{red}{$BM_1$};
draw (2,-5) -- (2,5) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
draw[-latex] (2,0) -- (4,0) node[below left,rotate=-90]{};
BM{600}{0.02}{0.2}{blue}{$BM_3$}
AddHorizontalGauss{100}{510}
end{tikzpicture}
end{document}
This can be made an animation.
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{calc}
begin{document}
%Brownian motion
newcommand{BM}[5]{
% points, advance, rand factor, options, end label
draw[#4] (0,0)
foreach x in {1,...,#1}
{ -- ++(#2,rand*#3) coordinate (aux-x) % <- added coordinate names
}
node[right] {#5};
}
newcommand{AddHorizontalGauss}[3]{
draw[#1] let p1=(aux-#2),p2=(aux-#3),n1={0.5*sqrt((x2-x1)*1pt/1cm)},
n2={3*n1},n3={0.895*n2} in pgfextra{pgfmathsetmacro{ymax}{n2}
pgfmathsetmacro{ynext}{n3}}
plot[variable=z,domain=-ymax:ymax,samples=101]
({x2+3*gauss(z,n1,0)*1cm},{y1+z*1cm})
($(x2,y1)+(0,-ymax)$) -- ($(x2,y1)+(0,ymax)$)
foreach X in {-ymax,-ynext,...,ymax}
{ (p1) -- ($(x2,y1)+({0*gauss(X,n1,0)},X*1cm)$)};
}
foreach Z in {120,130,...,540}
{begin{tikzpicture}[
declare function={gauss(x,y,z)=1/(y*sqrt(2*pi))*exp(-((x-z)^2)/(2*y^2));}]
pgfmathsetseed{17}
draw[help lines] (0,-8) grid (15,8);
BM{100}{0.02}{0.2}{red}{$BM_1$};
draw (2,-5) -- (2,5) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
draw[-latex] (2,0) -- (4,0) node[below left,rotate=-90]{};
BM{600}{0.02}{0.2}{blue}{$BM_3$}
AddHorizontalGauss{100}{Z}
end{tikzpicture}}
end{document}
Note that I have not computed the prefactor of the variance. This is just a cartoon. But this code will allow those who have a real random walk problem and compute the prefactor to produce a more realistic animation.
Now comes the comoving Gaussian. (To keep the answer reasonably "short" I only show the animation.)
documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{calc}
begin{document}
%Brownian motion
newcommand{BM}[5]{
% points, advance, rand factor, options, end label
draw[#4] (0,0)
foreach x in {1,...,#1}
{ -- ++(#2,rand*#3) coordinate (aux-x) % <- added coordinate names
}
node[right] {#5};
}
newcommand{AddComovingGauss}[3]{
draw[#1] let p1=(aux-#2),p2=(aux-#3),n1={0.5*sqrt((x2-x1)*1pt/1cm)},
n2={3*n1},n3={0.89*n2} in pgfextra{pgfmathsetmacro{ymax}{n2}
pgfmathsetmacro{ynext}{n3}}
plot[variable=z,domain=-ymax:ymax,samples=101]
({x2+3*gauss(z,n1,0)*1cm},{y2+z*1cm})
($(p2)+(0,-ymax)$) -- ($(p2)+(0,ymax)$)
foreach X in {-ymax,-ynext,...,ymax}
{ (p1) -- ($(p2)+({0*gauss(X,n1,0)},X*1cm)$)};
}
foreach Z in {120,130,...,540}
{begin{tikzpicture}[
declare function={gauss(x,y,z)=1/(y*sqrt(2*pi))*exp(-((x-z)^2)/(2*y^2));}]
pgfmathsetseed{17}
draw[help lines] (0,-8) grid (15,8);
BM{100}{0.02}{0.2}{red}{$BM_1$};
draw (2,-5) -- (2,5) coordinate[pos=0.6](x2) coordinate[pos=0.5] (y2);
draw[-latex] (2,0) -- (4,0) node[below left,rotate=-90]{};
BM{600}{0.02}{0.2}{blue}{$BM_3$}
AddComovingGauss{100}{Z}
end{tikzpicture}}
end{document}
And I also know that one could make the code somewhat shorter. This is an attempt to keep it very accessible.
edited Jan 2 at 22:47
answered Jan 2 at 20:34
marmotmarmot
92.1k4108201
92.1k4108201
The animation is beathtaking !!
– Julien-Elie Taieb
Jan 2 at 21:13
add a comment |
The animation is beathtaking !!
– Julien-Elie Taieb
Jan 2 at 21:13
The animation is beathtaking !!
– Julien-Elie Taieb
Jan 2 at 21:13
The animation is beathtaking !!
– Julien-Elie Taieb
Jan 2 at 21:13
add a comment |
Thanks for contributing an answer to TeX - LaTeX 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.
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%2ftex.stackexchange.com%2fquestions%2f468312%2fbrownian-motion-and-rotated-normal-distribution%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
Hi Marmot, I tried to sketch something. I want to show there is an effect on where the brownian can be at a future point $t$ depending on the distance from $s$ to this future point $(t-s)$. The distribution of probability is a Gaussian with a variance $sqrt{(t-s)}$
– Julien-Elie Taieb
Jan 2 at 20:25
1
I updated the details on my initial question. The variance of the distribution is determined by the distance to the future point we try to simulate. The farer the point, the wider the distribution.
– Julien-Elie Taieb
Jan 2 at 20:51
Its definitiely the right direction and even better with the animation feature. May I just add one thing ? the projection should be on a straight vertical line and not on the distribution itself. It shows the idea of the potential impact at that specific time and how it is distributed.
– Julien-Elie Taieb
Jan 2 at 21:39
Let us continue this discussion in chat.
– Julien-Elie Taieb
Jan 2 at 21:46
@Julien-ElieTaieb This seems to be a little bit unscientific/undidactic. The probability distribution applies before the time has passed, but the shown Brownian motion applies after the time has passed.
– Toscho
Jan 2 at 21:57