Debian Codegraph @

texmf-dist/doc/lualatex/luahyperbolic/examples/random-walks.tex

raw
1 \documentclass[a4paper]{article}
2 %\usepackage{fontspec}
3 %\setmainfont{Libertinus Serif}
4 %\usepackage{mathtools,unicode-math}
5 %\setmainfont{Libertinus Math}
6 \usepackage[margin=2.2cm]{geometry}
7 \usepackage[dvipsnames]{xcolor}
8 \usepackage{luacode}
9 \usepackage{../luahyperbolic}
10 \usepackage{hyperref}
11 \begin{document}
12 \title{Hyperbolic random walks}
13 \author{Damien Mégy}
14 \date{}
15 \maketitle
16 \pagestyle{empty}
17 \thispagestyle{empty}
18 Drawn with the \textbf{\textsf{luahyperbolic}} package. (\url{https://github.com/dmegy/luahyperbolic}) Every segment is a geodesic segment for the hyperbolic metric on the disk.
19
20 Notice how random walks in the hyperbolic disk tend to always escape to some point at infinity.
21 For a mathematical statement and proof of this, see: Marc Yor, \emph{Some Aspects of Brownian Motion , part II}, Birkhäuser, 1997.
22 See also the very nice animation at \url{https://www2.math.upenn.edu/~pstorm/hyperbolic_random_walk/}.
23 \begin{center}
24 \noindent
25 \begin{luacode*}
26 local speed = .5
27 local N = 16
28 local MAX_ITER = 300
29 local EPS = 1e-2
30 for i=1,N do
31 local P = complex(0,0)
32 local points = {P}
33 for k=1,MAX_ITER do
34 P = hyper.expMap(
35 points[#points],
36 speed*complex.exp_i(2*math.pi*math.random())
37 )
38 table.insert(points, P)
39 if complex.abs(P)>1-EPS then
40 texio.write_nl("break at k=" .. k)
41 break
42 end
43 end
44 local mycolor = "red!" .. math.round(100*i/N).. "!blue"
45 hyper.tikzBegin("scale=2")
46 hyper.drawPolylineFromTable(points, mycolor)
47 hyper.drawPoint(0)
48 hyper.tikzEnd()
49 end
50 \end{luacode*}
51 \end{center}
52 \end{document}