Graphics, Figures & Tables ⇒ Branching Brownian Motion
Branching Brownian Motion
I would like to plot a branching brownian motion but i couldn't find any function for brownian paths. Is it possible to plot it using TikZ?
NEW: TikZ book now 40% off at Amazon.com for a short time.

- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
Branching Brownian Motion
Welcome to the forum!
Yes, it would be easily possible with TikZ, or PSTricks, or calculations done with Lua. I would use pgfplots, since it gives us a coordinate system with axes and many options for customizing.
Jake gave an example here:
Jake explained it:
Yes, it would be easily possible with TikZ, or PSTricks, or calculations done with Lua. I would use pgfplots, since it gives us a coordinate system with axes and many options for customizing.
Jake gave an example here:
Code: Select all
Code, edit and compile here:
\documentclass[border=5mm]{standalone}\usepackage{pgfplots, pgfplotstable}% Create a function for generating inverse normally distributed numbers using the Box–Muller transform\pgfmathdeclarefunction{invgauss}{2}{%\pgfmathparse{sqrt(-2*ln(#1))*cos(deg(2*pi*#2))}%}% Code for brownian motion\makeatletter\pgfplotsset{table/.cd,brownian motion/.style={create on use/brown/.style={create col/expr accum={(\coordindex>0)*(max(min(invgauss(rnd,rnd)*0.1+\pgfmathaccuma,\pgfplots@brownian@max),\pgfplots@brownian@min)) + (\coordindex<1)*\pgfplots@brownian@start}{\pgfplots@brownian@start}},y=brown, x expr={\coordindex},brownian motion/.cd,#1,/.cd},brownian motion/.cd,min/.store in=\pgfplots@brownian@min,min=-inf,max/.store in=\pgfplots@brownian@max,max=inf,start/.store in=\pgfplots@brownian@start,start=0}\makeatother%
StefanThis approach uses pgfplotstable to calculate the Brownian motions as cumulative sums of random normally distributed values (thanks to horchler for pointing out the need for normality). You have to first initialise an empty table, using something like\pgfplotstablenew{200}\loadedtable
, and then you can draw the brownian motions using\addplot table [brownian motion] {\loadedtable};
.
You can set the initial value and the maximum and minimum values using
Code: Select all
\addplot table [brownian motion={start=0.5, min=-1, max=1}] {\loadedtable};
LaTeX.org admin