2


I am new with Tikz and I have a question which I did not manage to solve looking at other posts. I was wondering how to draw a figure in 2D, in which the first component (the x) is a function of x itself, say for simplicity exp(x), while the second is another function of a 1D Brownian motion.

I found some good suggestions here on how to draw a 2D Brownian motion, but I could not do it on my own. I get stuck if I try to insert a function in the command {--++(rand*0.2,rand*0.2)}.

Do you have any idea? Thanks a lot in advance.

  • Do you have the brown noise data already? – percusse Jun 3 '15 at 23:16
  • I have an idea. Draw a 3D graphic: x axis for x variable, y axis for f(x) and z axis for Brownian motion, then you rotate the graphic to see 2D graphic: f(x) vs Brownian motion ... – juanuni Jun 4 '15 at 0:33
1

Like this?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}


\draw[red] (0,0) \foreach \x in {1,...,300}{--++(0.03,{0.5*(floor(rand)*2.0+1.0)*sqrt(-ln(1-rand^2)/0.627)})};



\end{tikzpicture}

\end{document}

enter image description here

  • replace rand*0.2 with exp(rand*0.2) if you want exp of the Brownian motion. – JPi Jun 4 '15 at 1:04
  • @percusse: No, I do not have any data at hand. @JPi: If I write \foreach \x in {1,...,300}{--++(0.03,exp(rand*0.2))};, then it gives this type of error: "Package tikz Error: Giving up on this path. Did you forget a semicolon?" But, in fact, the code is the same as you posted. Oh, but now I replaced exp(rand*0.2) with exp{rand*0.2} and now it seems to work. – user79476 Jun 4 '15 at 8:00
  • @user79476 You should put {exp(rand*0.2)} instead of exp{rand*0.2}. Actually it surprises me that the latter even works. – Henri Menke Jun 4 '15 at 9:53
  • @user79476 How is this a solution? It is the plot of the random variable from a uniform distribution [-1,1]. Is it OK if it looks random enough? What happened to the exp(x) and brown noise? – percusse Jun 4 '15 at 11:25
  • Percusse is right; edited. New version gives an approximate Brownian motion. Take transformations of that as you please. – JPi Jun 4 '15 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.