# Adding jitter to a straight line

I have found a post about: How to add a jitter to a scatter plot with pgfplots. I'd like to add jitter to a straight green line to recreate this graph. .

Would this be the best way do you think? Also are the arrows decorations?

    \documentclass{standalone}
\usepackage{pgfplots}
\usepackage{amsmath}

\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin=-4,xmax=+0, ymin=-0.5,ymax=4.5, axis lines=left]

samples=100]
{2}
node [midway, above right] {\small $\bar{U}$ Time-average velocity};

\end{axis}
\end{tikzpicture}
\end{document}

• Perhaps make this in paint? – HCAI Jun 18 '13 at 13:16
• No, perhaps put a clear image for what you mean for jitter to a straight green line: this might clarify a bit what you're wondering to everybody. :) – Claudio Fiandrino Jun 18 '13 at 13:21
• Just apply the theory of efficient markets to the green line, and on the basis of no-arbitrage, it should converge with the fair value. – Nicholas Hamilton Jun 18 '13 at 13:30

This approach is really similar to vrleboss' suggestion, but in order to fit the arrow for the fluctuating velocity, we'll need to simulate autocorrelated noise (or try lots of realisations of the uncorrelated noise).

Here I've used a product of two cosine functions as the base function, and then added random noise on top: \documentclass{standalone}
\usepackage{pgfplots}
\usepackage{amsmath}

\begin{document}
\begin{tikzpicture}
\pgfmathsetseed{1}
\begin{axis}[xmin=-4,xmax=+0, ymin=-0.5,ymax=4.5, axis lines=left,
clip=false]

samples=2]
{2}
node [right] {\small $\bar{U}$ Time-average velocity};
samples=100]
{2+0.8*cos(x*300)*cos(x*50)+rand/5}
node [red, right] {\small $U$ Instantaneous velocity}
coordinate [pos=0.25] (point);
\draw [ultra thick, blue, latex-latex] (point) -- (point|-{axis cs:0,2}) node [pos=0, anchor=-160] {$u'$ Fluctuating velocity};
\end{axis}
\end{tikzpicture}
\end{document}

• To have an even nicer curve add the smooth option to \addplot[...] – vrleboss Jun 18 '13 at 14:07

I would use the rand function. The decoration produces non-causal curves.

\begin{tikzpicture}
\begin{axis}[xmin=-4,xmax=+0, ymin=-0.5,ymax=4.5, axis lines=left]

node [midway, above right] {\small $\bar{U}$ Time-average velocity}; 