軸環境内でブラウン運動を描くにはどうすればいいでしょうか?

軸環境内でブラウン運動を描くにはどうすればいいでしょうか?

0から1までの標準的なブラウン運動を描きたい。この答え、私は次のことを試しました:

\documentclass{article}

\usepackage{pgfplots, tikz}
\pgfplotsset{compat = newest}

\newcommand{\Emmett}[5] % color, x0, dt, n 
{
    \draw[#1] (0, #2)
    \foreach\x in {1, ..., #4} {
        -- ++(#3, rand * #3)
    }
    node[right] {#5};
}

\begin{document}

\begin{tikzpicture}[>=latex]
    \begin{axis}[
        axis x line = center,
        axis y line = center,
        xtick = {0, ..., 1},
        ytick = {-1, ..., 1},
        xlabel = {$t$},
        ylabel = {$x$},
        xlabel style = {right},
        ylabel style = {above},
        xmin = 0,
        xmax = 1.1,
        ymin = -1,
        ymax = 1]

        \Emmett{black}{0}{.01}{100}{};
    \end{axis}
\end{tikzpicture}

\end{document}

出力は

ここに画像の説明を入力してください

したがって、明らかに何かが間違っています。\Emmettマクロを完全に理解していないことを認めなければなりませんが、おそらく何かが間違っているのでしょう。コードが実際に行うべきことは次のとおりです。

t = 0;
x = x0;

for (i = 0; i < n; ++i)
{
    plot (t, x);

    let xi be a sample from the standard normal distribution;
    x += sqrt(dt) * xi;
}

では、マクロをどのように調整すればよいのでしょうか?標準的なブラウン運動の軌跡は実際には次のようになります。

ここに画像の説明を入力してください

関連情報